首页 > 技术文章 > vue项目中引入jquery

mamifeng 2020-08-26 09:53 原文

1. 在package.json中的dependences中引入jquery的版本

 

 

 2.第二步在webpack.base.conf.js文件中加入如下内容:

const webpack = require("webpack")

 

 

'jquery': 'jquery'

 

 

 
 
plugins:[
    new webpack.ProvidePlugin({
      $:'jquery',
      jQuery: 'jquery'
    })
  ]

 

 3.第三步:安装 npm install jquery --save

4.在需要用到的地方引入jquery

import $ from 'jquery'

推荐阅读