1.安装 jquery
npm install jquery --save
2.修改webpack.base.conf.js配置文件
位置: build/webpack.base.conf.js
2-1 创建webpack对象
var webpack = require("webpack")
2-2 在module.exports 加入配置
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
"window.jQuery": "jquery"
})
]
3 验证是否成功
重启项目
输出$
到此为止JQ引入成功