vue项目中引入jquery

  1. 安装jquery
npm install jquery
  1. 在webpack.base.conf.js中加入一行代码
var webpack = require("webpack")
  1. 在webpack.base.conf.js中module.exports的最后加入这行代码
plugins: [
  new webpack.optimize.CommonsChunkPlugin('common.js'),
  new webpack.ProvidePlugin({
    jQuery: "jquery",
    $: "jquery"
  })
]
  1. 在main.js中引入,加入下面这行代码,全局引入
import $ from 'jquery'

或者下面这行也可

window.$ = require('jquery') 

你可能感兴趣的:(vue.js,jquery)