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

相关推荐
知识分享小能手13 分钟前
Vue3 学习教程,从入门到精通,Vue3 中使用 Axios 进行 Ajax 请求的语法知识点与案例代码(23)
前端·javascript·vue.js·学习·ajax·vue·vue3
一只开心鸭!17 小时前
vue+elementui实现问卷调查配置可单选、多选、解答
javascript·vue.js·elementui
YGY Webgis糕手之路18 小时前
Cesium 快速入门(三)Viewer:三维场景的“外壳”
前端·经验分享·笔记·vue·web
YGY Webgis糕手之路20 小时前
Cesium 快速入门(二)底图更换
前端·经验分享·笔记·vue
YGY Webgis糕手之路21 小时前
Cesium 快速入门(七)材质详解
前端·经验分享·笔记·vue·web
YGY Webgis糕手之路1 天前
Cesium 快速入门(八)Primitive(图元)系统深度解析
前端·经验分享·笔记·vue·web
YGY Webgis糕手之路1 天前
Cesium 快速入门(四)相机控制完全指南
前端·经验分享·笔记·vue·web
YGY Webgis糕手之路1 天前
Cesium 快速入门(六)实体类型介绍
前端·经验分享·笔记·vue·web
YGY Webgis糕手之路1 天前
Cesium 快速入门(一)快速搭建项目
前端·经验分享·笔记·vue·web
sunbyte1 天前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | 3dBackgroundBoxes(3D背景盒子组件)
前端·javascript·vue.js·3d·vue