Vue2项目打包优化时,引入element-ui 配置 CDN 加速时报错出现报错信息:Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')

老师说出现这个问题的原因是,如果你完整引入了 Element,它会为 Vue.prototype 添加如下全局方法:$alert, $promp......

 

 所以,如果想要正常使用Element-UI,需要先引入Vue

 在 externals 下把 vue 也一起配了

 

此时再重新打包,控制台就没有报错了,试了下,项目也能正常运行

Logo

前往低代码交流专区

更多推荐