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

简介: 配置无误、代码未报错,运行时页面空白,F12控制台报错: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,然后重新启动,解决!

相关文章
|
1天前
|
前端开发 小程序 JavaScript
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
|
17天前
|
缓存 JavaScript 测试技术
如何创建一个VUE3项目并使用Element UI插件
如何创建一个VUE3项目并使用Element UI插件
|
1月前
Vue3+Vite+Pinia+Naive后台管理系统搭建之四:Naive UI 组件库的安装和使用
Vue3+Vite+Pinia+Naive后台管理系统搭建之四:Naive UI 组件库的安装和使用
48 1
|
1月前
webpack版本问题 Cannot read property ‘createHash‘ of undefined
webpack版本问题 Cannot read property ‘createHash‘ of undefined
|
1月前
|
iOS开发 MacOS
TypeError: Cannot read property ‘shop‘ of undefined
TypeError: Cannot read property ‘shop‘ of undefined
19 0
|
1月前
|
机器学习/深度学习
TypeError: Cannot read property ‘name‘ of undefined at Qe.onShow
TypeError: Cannot read property ‘name‘ of undefined at Qe.onShow
29 0
|
1天前
|
JavaScript 前端开发 API
|
1天前
|
JavaScript 前端开发 网络架构
Vue如何实现页面跳转路由,实现单页面跳转
Vue如何实现页面跳转路由,实现单页面跳转
|
1天前
|
JavaScript
|
1天前
|
JavaScript 前端开发
Vue,如何引入样式文件
Vue,如何引入样式文件