1)安装:
npm install jquery --save
2)配置vue.config.js
module.exports = {
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
}
}
3)在需要用到的vue组件中引入:
import $ from 'jquery