Vue----Vue安装配置JQuery
方式一:
1.安装jquery
npm install jquery --save-dev
2.build/webpack.base.conf.js中,
导入:var webpack = require('webpack');
最下面添加:
plugins: [
new webpack.ProvidePlugin({
$:"jquery",
jQuery:"jquery",
"window.jQuery":"jquery"
})
]
3.vue文件中无需导入,可直接使用$和jQuery
方式二:
1:npm install jquery
2:在build文件夹下的webpack.base.conf.js进行配置
(1)const webpack = require("webpack")
(2)在module.exports里面加入
plugins: [
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery:"jquery",
$:"jquery"
})
],
如图
3:在需要用到jquery的页面引入
import $ from 'jquery';