vue3 使用 elementUi: ./lib/theme-chalk/index.css is not exported from package

目录

  • [1. 在 vue3 中使用 element-ui](#1. 在 vue3 中使用 element-ui)
  • [2. 如果启动报错:Module not found: Error: Package path ./lib/theme-chalk/index.css is not exported from package](#2. 如果启动报错:Module not found: Error: Package path ./lib/theme-chalk/index.css is not exported from package)

1. 在 vue3 中使用 element-ui

在 vue3 中使用 element-ui,我们的流程一般是这样的:

  1. 安装Element-Plus

    shell 复制代码
    npm i element-plus -S
  2. main.js 中全局引入 element-plus

    javascript 复制代码
    import { createApp } from 'vue'
    import ElementPlus from 'element-plus';
    import 'element-plus/dist/index.css';
    import App from './App.vue'
    
    createApp(App).use(ElementPlus).mount('#app')
  3. 在 HelloWorld.vue 中测试一下

    html 复制代码
    <template>
      <div class="hello">
        <el-button type="primary">搜索</el-button>
      </div>
    </template>
  4. npm run serve 跑一下服务

2. 如果启动报错:Module not found: Error: Package path ./lib/theme-chalk/index.css is not exported from package

那就说明,main.js 中 element-plus 的 index.css 路径给配错了,这时候只需要打开 /node_modules/element-plus 去找到 index.css ,然后更改 main.js 中的路径就 OK 了。

相关推荐
Pu_Nine_92 天前
Vue3+TS+Express 转 Nuxt4 全栈开发笔记(Drizzle ORM + MySQL)
前端·vue·express·nuxt.js·全栈框架
脾气有点小暴2 天前
ECharts 伪 3D 柱状图完整注释 + 实现原理说明
前端·3d·信息可视化·vue·echarts
sugar__salt3 天前
Vue3 核心特性深度解析:v-model、ref 属性与 nextTick 完全指南
前端·javascript·vue.js·前端框架·vue
勇往直前plus4 天前
Vue3(篇四)单页面应用到路由管理
javascript·typescript·前端框架·vue
勇往直前plus4 天前
Vue3(篇三) Element Plus
前端·javascript·typescript·vue
shawxlee5 天前
vue3+axios挑战最简洁实用的配置封装+接口调用:请求拦截器、响应拦截器、通用请求方法(单个请求/并发请求/下载文件)、统一接口管理
前端·经验分享·vue·接口·axios·api
RuoyiOffice7 天前
超级个体接私活必看:后端+前端+移动端三端一体企业管理系统怎么选(2026)
java·spring boot·vue·uniapp·全栈·企业管理·接私活
狗凯之家源码网7 天前
机车圈系统核心功能与实战效果展示
vue·node
无巧不成书02188 天前
Vue+Vue-CLI全平台零基础搭建教程
前端·javascript·vue.js·vue·前端开发·vue-cli·前端环境搭建
森林的尽头是阳光9 天前
tree回显问题
javascript·vue.js·elementui