Step1 在项目目录运行如下指令, 安装jQuery包
npm install jquery --save-dev
Step2 编辑webpack.base.config.js
首先里面要有这么一句
const webpack = require('webpack')
然后在module.exports对象中, plugins节点里, 要包含下面的内容
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
]
如果没有plugins节点, 就请复制以上代码到module.exports对象中
Step3 编辑.eslintrc.js
在module.exports对象的globals节点里, 要包含下面的内容
globals: {
'$': false,
'jquery': false
}
Step4 重新完整编译
npm run web