vue3配置全局jquery

1、安装jquery

npm install jquery

2、在vue.config.js进行如下配置

const { defineConfig } = require("@vue/cli-service");
const webpack = require('webpack')
module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack:{
    plugins:[
      new webpack.ProvidePlugin({
        $:'jquery',
        jQuery:'jquery',
        'window.jQuery':'jquery'
      })
    ]
  }
});

3、在.eslintrc.js文件中添加

4、重启项目 

猜你喜欢

转载自blog.csdn.net/m0_73334325/article/details/130872907
今日推荐