1、安装jquery
npm install jquery –save-dev
打开build文件夹下的webpack.base.conf.js
头部添加代码:
const webpack = require("webpack");
module.exports 中添加代码
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
在入口文件main.js中加入代码:
import $ from 'jquery' ;
测试: