高版本jQuery替换现有项目中低版本jQuery问题(MacOS下获取源代码编译jQuery)

操作系统:MacOS

项目开发工具:VS2015

Git上获取jQuery代码(https://github.com/jquery/jquery),本文版本jQuery v3.5.1

根据Git上的说明,需要安装node.js

下载后安装,安装完成后,执行下列命令确认是否安装成功

 进入jQuery所在目录jquery-3.5.1,执行下列操作

MacBook-Air:jquery-3.5.1 apple$ sudo npm install && grunt

Password:输入用户密码

npm WARN grunt-karma@3.0.1 requires a peer of karma@^3.0.0 but none is installed. You must install peer dependencies yourself.

 

up to date in 4.558s

 

28 packages are looking for funding

  run `npm fund` for details

 

Running "eslint:dev" (eslint) task

 

Running "build:all:*" (build) task

>> File 'dist/jquery.js' created.

 

Running "uglify:all" (uglify) task

>> 1 sourcemap created.

>> 1 file created 287.63 kB89.51 kB

 

Running "remove_map_comment" task

 

Running "dist:*" (dist) task

 

Running "qunit_fixture" task

>> Updated ./test/data/qunit-fixture.js.

 

Running "babel:tests" (babel) task

 

Running "eslint:dist" (eslint) task

 

Running "node_document_missing" task

 

Running "node_document_passed" task

 

Running "node_document_present_originally" task

 

Running "node_iterable_with_native_symbol" task

 

Running "compare_size:files" (compare_size) task

>> Error: Command failed: git branch --no-color --verbose --no-abbrev --contains HEAD

>> fatal: Not a git repository (or any of the parent directories): .git

   raw     gz Sizes                                                           

287630  84860 dist/jquery.js                                                   

 89476  30869 dist/jquery.min.js                                              

 

   raw     gz Compared to last run                                            

     =      = dist/jquery.js                                                   

     =      = dist/jquery.min.js                                              

 

Done.

编译完成

将生成的jquery.min.js复制到项目中替换现有版本,现有版本为2.1.4。替换完验证一下,出现以下错误

经分析查阅,该错误是由

$("").load(function(){

})

这种写法引起,这种写法在3.5.1中已经不支持了,在3.5.1中需要改为

$("").on('load',function(){

})

修改后验证,成功。升级版本后是否还有其它问题,还需要更多验证。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值