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

相关推荐
D_C_tyu5 天前
Vue3 + Element Plus | el-table 多级表头表格导出 Excel(含合并单元格、单元格居中)第二版
vue.js·elementui·excel
跟着珅聪学java5 天前
Element UI 的 el-input组件触发 blur事件
javascript·vue.js·elementui
Komorebi゛5 天前
【Vue + Element Plus】el-tree树结构样式改造,添加转折线
前端·javascript·vue.js·elementui
花生柿子5 天前
在elementui可横向滚动的table中,操作列有时候会透视下面的行
前端·javascript·elementui
南_山无梅落5 天前
从传统Web到API驱动:使用Django REST Framework重构智能合同审查系统
重构·django·vue·drf
敲代码的小吉米5 天前
Element Plus 表格中的复制功能使用指南
前端·javascript·elementui
PD我是你的真爱粉6 天前
API 请求封装(Axios + 拦截器 + 错误处理)
前端框架·vue
biyezuopinvip8 天前
基于Spring Boot的投资理财系统设计与实现(毕业论文)
java·spring boot·vue·毕业设计·论文·毕业论文·投资理财系统设计与实现
biyezuopinvip8 天前
基于Spring Boot的投资理财系统设计与实现(任务书)
java·spring boot·vue·毕业设计·论文·任务书·投资理财系统设计与实现
huohuopro8 天前
Vue3 Webview 转 Android 虚拟导航栏遮挡问题记录
android·vue