vue3 使用 elementUi: ./lib/theme-chalk/index.css is not exported from package

博客介绍了在Vue3中使用Element-UI的流程,包括安装Element-Plus、在main.js中全局引入、在HelloWorld.vue中测试及运行服务。还提到若启动报错“Module not found: Error: Package path./lib/theme-chalk/index.css is not exported from package”,是main.js中element-plus的index.css路径配置错误,需更改路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 在 vue3 中使用 element-ui

在 vue3 中使用 element-ui,我们的流程一般是这样的:

  1. 安装Element-Plus

    npm i element-plus -S
    
  2. main.js 中全局引入 element-plus

    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 中测试一下

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

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

364.99°

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值