一、在项目根目录下执行:
npm install jquery
二、在 vue.cofnig.js 中加入下面内容:
const webpack = require("webpack"); module.exports = { ...省略一些内容..., configureWebpack: { //支持jquery plugins: [ new webpack.ProvidePlugin({ $:"jquery", jQuery:"jquery", "windows.jQuery":"jquery" }) ] },
}
三、在 .eslintrc.js 中加入下面内容:
env: { node: true, jquery: true //此处配置意思为全局引入jquery },
原文:https://www.jianshu.com/p/5a196c2df13e