vue引入jQuery第三方插件比如jquery-fly报错jQuery is not defined?

1.安装jquery:

npm install jquery --save

2.如果webpack不能直接安装jquery的第三方插件,比如jquery-fly,可以直接将插件下载到项目文件夹:

jquery-fly的github地址如下:https://github.com/amibug/fly

下载好可以放到src/common/js/jquery.fly.min.js类似这样的本地路径

3.新建 jquery-vendor.js

import $ from 'jquery'
window.$ = $
window.jQuery = $
export default $

4.再引用XXX.vue中引用(../是相对路径,请根据自己项目执行调整路径):

 import $ from '../../common/js/jquery-vendor';
 import jqueryFly from '../../common/js/jquery.fly.min';

参考链接:https://blog.csdn.net/jx950915/article/details/79486807

猜你喜欢

转载自blog.csdn.net/plm609337931/article/details/86479283