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

相关推荐
雪芽蓝域zzs9 小时前
第3节:el-select 弹窗定位、滚动穿透与挂载容器(popper-append-to-body /teleported)
vue.js·elementui
雪芽蓝域zzs19 小时前
第 2 节:基础扩展 - 下拉弹窗常用原生属性
vue.js·elementui
雪芽蓝域zzs1 天前
Vue3 + Element Plus el-select 下拉弹窗
vue.js·elementui
zzZ··*2 天前
CodeBuddy 用量看板:本地解析 Token 与积分消耗,不联网不上传
python·vue·ai编程
EatFan2 天前
Go语言全栈实战:基于 Gin + Vue + JWT + RBAC 从零搭建前后端分离权限管理系统
vue.js·golang·go·vue·gin·jwt·rbac
就叫年华吧丶3 天前
长文档点目录定位总是不准?一个 content-visibility + 平滑滚动引发的连环坑(Vue3 实战)
前端·javascript·算法·vue
今年下半年5 天前
【VUE3】移动端:使用腾讯地图显示区域统计与放大显示资产点位
javascript·前端框架·vue·地图
志尊宝5 天前
Vue3 零基础每日笔记(054):Pinia 三件套详解——state / getters / actions 全搞懂
前端·javascript·vue.js·vue·前端开发
朱 欢 庆5 天前
el-table 表格组件二次封装
javascript·vue.js·elementui
志尊宝11 天前
Vue3 零基础每日笔记(055):组件里正确使用 store——storeToRefs 解构与 $patch 批量修改
笔记·vue·html·前端开发·软件开发