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

相关推荐
Curvatureflight13 小时前
前端国际化 i18n 落地实践:语言包、动态文案和格式化问题怎么处理?
前端·c++·vue
优雅格子衫18 小时前
uniapp 拍照相册选取后超级好用的裁剪组件,增加水印完全自定义
开发语言·前端·javascript·uni-app·vue
路光.18 小时前
uniapp中解决webview在app中调用,有过渡空白问题,增加过渡动效
uni-app·vue·app·uniapp
zhangyao9403301 天前
开发pc端时,表格的高度怎么设置才能铺满页面
前端·javascript·elementui
暗冰ཏོ2 天前
《2026 Vue2 + Vue3 完整学习指南:基础语法、路由缓存、登录拦截、项目实战与面试题》
前端·vue.js·vue·vue3·vue2
七仔啊2 天前
cad文件在线查看
vue
相忘于江湖4265433 天前
vs code 代码保存自动格式化
前端·vue
mengqudoh3 天前
elementui el-table 表头固定功能
javascript·vue.js·elementui
study-Java4 天前
校园失物招领平台
java·spring boot·vue·intellij-idea·visual studio code
MaCa .BaKa4 天前
53-智慧工地人员考勤与工时管理系统
java·spring boot·mysql·tomcat·vue·maven