【Vue】VUE引用element-ui報錯Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)-CSDN博客

来源: 【Vue】VUE引用element-ui報錯Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)-CSDN博客

报错代码如下:
app.js:160 Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype’)
at eval (types.js?8ad0:39:1)
at ./node_modules/element-ui/lib/utils/types.js (chunk-vendors.js:834:1)
at __webpack_require__ (app.js:157:33)
at fn (app.js:402:21)
at eval (util.js?40a4:19:1)
at ./node_modules/element-ui/lib/utils/util.js (chunk-vendors.js:845:1)
at __webpack_require__ (app.js:157:33)
at fn (app.js:402:21)
at eval (format.js?5a92:49:1)
at ./node_modules/element-ui/lib/locale/format.js (chunk-vendors.js:501:1)

报错原因:
因为我创建的是VUE3项目,VUE的版本为3.2.13,而element-ui只适用于VUE2项目,经过我查询,element-plus适用于VUE3项目。为了更加充分的证明这个问题,我去创建了一个VUE2项目,版本为2.6.14,是能够引用element-ui。

解决方案
1.先确认自己项目是VUE2项目还是VUE3项目,在package.json文件里面查看,如下图所示。

2.根据VUE版本,执行以下其中一步
A.如果是VUE2项目,安装element-ui,指令如下

npm i element-ui –save

B.如果是VUE3项目,安装element-plus,指令如下

npm i element-plus –save

总结
Vue2项目安装element-ui,VUE3项目安装element-plus。
————————————————
版权声明:本文为CSDN博主「里奥♚」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_46533551/article/details/129042824

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏