1、执行安装jquery依赖包命令
npm install jquery --save
2、webpack 配置
新建vue.config.js文件,添加以下代码。
const webpack = require('webpack')
module.exports = {
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
}
}
3、在main.js里导入jQuery
import "jquery"