Vue3.x 引入 jQuery

一、在项目根目录下执行:

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

 

posted @ 2020-06-01 14:38    阅读(3927)  评论(0编辑  收藏  举报