Article Directory
If the following three steps are done well, the problem of jquery is not define will not appear
Install
npm i jquery -S
Referenced in main.js
import $ from 'jquery'
Vue.prototype.$ = $
Modify webpack configuration
In the build directory: build/ webpack.base.conf.js
//webpack.base.conf.js
//一定要先定义webpack变量,否则报错webpack not define
const webpack = require('webpack');
module.exports = {
plugins: [
new webpack.optimize
.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
]
}