vue cli3 引用外部js方法
vue引用webVideoCtrl.js1、在vue.config.js中添加chainWebpack: config => {config.resolve.alias.set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components')).set...
vue引用webVideoCtrl.js
1、在vue.config.js中添加
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
.set('_c', resolve('src/components'))
.set('webVideoCtrl',resolve('src/assets/js/webVideoCtrl.js'))
config.entry('index')
.add('babel-polyfill')
}
在对应的vue中import webVideoCtrl
2、如果需要全局引用, vue.config.js中配置 plugins,无需 import 全局可用
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'windows.jQuery': 'jquery',
‘webVideoCtrl’:‘webVideoCtrl’
})
]
}
更多推荐
所有评论(0)