vue中cdn引入element-ui 报错“vue-router.min.js:6 ReferenceError: ElementUI is not defined“解决
index.html页面引入<link rel="stylesheet" href="plug/element-ui/theme-chalk/index.css" rel="external nofollow" ><script src="js/vue.min.js"></script><script src="js/vue-router.min.js"&
·
index.html页面引入
<link rel="stylesheet" href="plug/element-ui/theme-chalk/index.css" rel="external nofollow" >
<script src="js/vue.min.js"></script>
<script src="js/vue-router.min.js"></script>
<script src="js/axios.min.js"></script>
<script src="plug/element-ui/element-ui.js"></script>
在vue.config.js页面设置
configureWebpack: {
externals: {
'vue': 'Vue',
'vue-router':'VueRouter',
'axios':'axios',
'element-ui':'ElementUI'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'windows.jQuery': 'jquery',
})
]
},
报错:vue-router.min.js:6 ReferenceError: ElementUI is not defined
解决:
cdn 版本的 element-ui
设置的全局变量是 ELEMENT
configureWebpack: {
externals: {
'vue': 'Vue',
'vue-router':'VueRouter',
'axios':'axios',
'element-ui':'ELEMENT'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'windows.jQuery': 'jquery',
})
]
},
更多推荐
已为社区贡献10条内容
所有评论(0)