Vue3引入element-ui报错:Uncaught TypeError: Cannot read property ‘prototype‘ of undefined


为什么

你写的引入方式可能是这种

import ElementUI from "element-ui";
import "element-plus/lib/theme-chalk/index.css";
Vue.use(ElementUI)

配置无误、代码未报错,运行时页面空白,F12控制台报错:
Uncaught TypeError: Cannot read property ‘prototype’ of undefined

解决办法

原因就是在main.js引入element-ui方式错误(vue3.0的坑)

先下载

npm install element-plus --save

vue3中正确引入方式如下

import ElementUI from "element-plus";
import "element-plus/dist/index.css"
createApp(App).use(store).use(router).use(ElementUI).mount('#app')

一定要注意哦!!! vue3是element-plus,然后重新启动,解决!

猜你喜欢

转载自blog.csdn.net/zhaojiaxing123/article/details/129520076