- npm install jquery --save
dependencies:{
"jquery":"^2.2.1"
}
2.在webpack.base.conf.js中加入一行代码
var webpack=require("webpack")
var webpack = require('webpack')
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
在webpack.base.conf.js中module.exports的最后加入这行代码,
plugins: [
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
],
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
3.在main.js中引入,加入下面这行代码,全局引入
import $ from 'jquery'
网友评论