当前位置:   article > 正文

Vue2项目打包时,引入element-ui 配置 CDN 加速时报错 Cannot read properties of undefined (reading ‘prototype‘)_uncaught typeerror: cannot read properties of unde

uncaught typeerror: cannot read properties of undefined (reading 'prototype

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

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

 

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

 在 externals 下把 vue 也一起配了

 

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/493164
推荐阅读
相关标签
  

闽ICP备14008679号