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,然后重新启动,解决!

相关文章
Uncaught TypeError: Cannot use ‘in‘ operator to search for ‘path‘ in undefined
Uncaught TypeError: Cannot use ‘in‘ operator to search for ‘path‘ in undefined
Uncaught runtime errors: × ERROR Cannot read properties of undefined (reading ‘ vue2&vue-router兼容性问题
Uncaught runtime errors: × ERROR Cannot read properties of undefined (reading ‘ vue2&vue-router兼容性问题
1015 0
|
前端开发 JavaScript
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
586 0
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式
|
JavaScript 前端开发
Vue报错“ Uncaught TypeError: Cannot read property ‘use‘ of undefined”
Vue报错“ Uncaught TypeError: Cannot read property ‘use‘ of undefined”
1210 1
|
自然语言处理 JavaScript
Uncaught TypeError: Cannot read property of undefined
vue中出现这种错误导致这种错误产生的原因是在选项 property 或回调上使用箭头函数 created: () => console.log(this.a) 或 vm.$watch('a', newValue => this.myMethod()) 1 2 因为箭头函数并没有 this,this 会作为变量一直向上级词法作用域查找,直至找到为止
327 0
|
前端开发 小程序 JavaScript
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
404 0
|
JavaScript
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
554 0