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 了。

相关推荐
王小二(海阔天空)14 小时前
个人文章合集 - 前端相关
前端·css·vue·jquery
码农00021 小时前
Vue2 + ElementUI + axios + VueRouter入门
前端·javascript·elementui
osnet1 天前
showdoc二次开发
node.js·vue
做一个有用的阿吉1 天前
element-ui 通过按钮式触发日期选择器
elementui
前端张三2 天前
view deign 和 vue2 合并单元格的方法
vue
《独白》2 天前
elementUI表格中某个字段(state)使用计算属性进行转换为对应中文显示
前端·vue.js·elementui
-心铭-3 天前
有关若依菜单管理的改造
学习·vue
Snailmi3 天前
Spring Boot+VUE《班级综合测评管理系统》
java·spring boot·后端·vue·毕业设计
dy17173 天前
el-table按照查询条件再对应行数据进行高亮,并可以定位到某行
javascript·vue.js·elementui
潜心专研的小张同学3 天前
pnpm依赖安装失败解决|pnpm项目从一个文件夹复制到另一个文件夹运行失败问题解决-以vbenAdmin项目为例
前端·javascript·vscode·npm·vue·pnpm