

一、引入jquery
步骤:
1. 安装jquery
$ npm install jquery --save-dev
2.在webpack.config.js 添加内容
+ const webpack = require("webpack");
module.exports = {
entry: './index.js',
output: {
path: path.join(__dirname, './dist'),
publicPath: '/dist/',
filename: 'index.js'
},
+ plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery'
})
]
}3.在入口文件index.js 里面添加内容
import $ from 'jquery' ;
