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

相关推荐
@AfeiyuO1 小时前
Vue3 玫瑰图
vue·echarts
i_am_a_div_日积月累_2 小时前
el-tree半选回显问题;el-tree获取半选节点id
javascript·vue.js·elementui
自然 醒2 小时前
elementUI的select下拉框如何下拉加载数据?
前端·javascript·elementui
running up2 天前
Pinia 完整使用指南
vue
码农秋2 天前
Element Plus DatePicker 日期少一天问题:时区解析陷阱与解决方案
前端·vue.js·elementui·dayjs
安_2 天前
<style scoped>跟<style>有什么区别
前端·vue
辛-夷2 天前
TS封装axios
前端·vue.js·typescript·vue·axios
@AfeiyuO2 天前
Vue3 矩形树图
vue·echarts
weixin_422555423 天前
ezuikit-js官网使用示例
前端·javascript·vue·ezuikit-js
zhz52143 天前
代码之恋(第十五篇:分布式心跳与网络延迟)
网络·分布式·ai·重构·vue·结对编程