步骤:

1、安装jquery:npm install jquery

2、修改配置:在webpack.base.conf.js文件加入

var webpack=require('webpack');
module.exports = {
plugins:[
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery"
})
]
}
3、在main.js中全局引用,如下图
import $ from 'jquery'
vue组件引入jquery
5、在home.vue使用发现eslint语法检测$错误,修改.eslintrc.js配置文件
jquery: true
vue组件引入jquery
6、测试程序,看控制台输出
vue组件引入jquery

 

前方有坑预警,控制台有错误Uncaught ReferenceError: __WEBPACK_AMD_DEFINE_ARRAY__ is not defined的错误

npm install jquery@^2.2.4 --save

感谢:https://www.cnblogs.com/bluey/p/6531694.html

 

 

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案