转自:https://blog.51cto.com/u_15119353/5046315
安装 jQuery
npm install jquery
在src同级目录下新建 vue.config.js 文件
const webpack = require('webpack')
module.exports = {
//引入jquery
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
}
}
局部引入
在需要使用 jQuery 的页面引入即可。
import $ from 'jquery';
Google Chrome
Windows 10