首先在package.json里的dependencies加入"jquery" : "^2.2.3",然后install
在webpack.base.conf.js里加入
var webpack = require("webpack")
在module.exports的最后加入
plugins: [ new webpack.optimize.CommonsChunkPlugin('common.js'), new webpack.ProvidePlugin({ jQuery: "jquery", $: "jquery" }) ]
然后一定要重新 run dev
在main.js 引入就ok了import $ from 'jquery'
在重新npm run dev之前可能还会提示This dependency was not found:
* jquery in ./src/main.js
to Install it, you can run : npm install --save jquery
下面就简单了,
直接使用
npm install --save jquery
安装jquery完成之后
就可以顺利的使用npm run dev了.