1、在项目中安装jquery。
npm install jquery --save-dev

2、在项目根目录下的build/webpack.base.conf.js文件中:
① 先写以下代码
var webpack = require(“webpack”)

②在module.exports的最后写
plugins: [
new webpack.optimize.CommonsChunkPlugin(‘common.js’),
new webpack.ProvidePlugin({
jQuery: “jquery”,
$: “jquery”
})
]

3、在根目录下的\src\main.js中引入
import $ from ‘jquery’

4、此时在vue中全局引入了jquery,可以在script中写jquery语法的代码。
4468

被折叠的 条评论
为什么被折叠?



