vue組件引入cdn的示例:
1.index.html中添加第一個script鏈接:
src=“https://cdn.bootcss.com/vue/2.5.10/vue.min.js”>
2.vue_cli3架構的vue在vue.config.js中添加
configureWebpack: config => {config.externals = {
‘vue’: ‘Vue’
}
}
//在其它版本中webpack.base.conf.js中
module.exports = {
entry: {
app: ‘./src/main.js’
},
externals:{
‘vue’: 'Vue‘
},
}
3.main.js中注釋import Vue from ‘vue’