1、 npm install jquery --save
2、在webpack.base.config.js中添加
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
......
plugins: [
new webpack.ProvidePlugin({
jQuery: "jquery",
jquery:"jquery",
$: "jquery",
“window.jQuery”:"jquery"
})
]
}
3、若有eslint检查,在.eslint.js中的module.export中添加
env: {
// 原有
browser: true,
// 添加
jquery: true
}
4、在main.js中导入jQuery
import 'jquery'