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

报错代码如下:

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。

  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值