bug原因: 使用到weapp-cookie 包在iOS下对wx.uploadFile、wx.downFile读本地文件有兼容问题。 由于引用了weapp-cookie包,调用wx.downloadFile时,这个api会被包内部的downloadFileProxy改写掉,然后问题出在 miniprogram_npm\weapp-cookie\index.js 这个文件中 其中第2411行: var responseCookies = response.header ? response.header['Set-Cookie'] || response.header['set-cookie'] : ''; 通过这行语句拿到后端设置的cookie,在安卓系统中是一个字符串没有问题,但在IOS系统中是一个数组,所以在IOS系统的后续的replace操作中,对数组replace就会报错,安卓则不会。 解决方案: weapp-cookie 更换成weapp-cookie2 , 文档:https://www.npmjs.com/package/weapp-cookie2
iOS 手机上调用 wx.uploadFile 上传wxfile://temp_本地文件时出现错误?iOS 手机上调用 wx.uploadFile 上传wxfile://temp_文件时出现错误,而在安卓手机和开发者工具模拟器上没有错误. [图片] success和fail都没有发生回调, 报错如下: MiniProgramError o.replace is not a function. (In 'o.replace(/\;([^\s\;]*?(?=\=))/gi, ",$1")', 'o.replace' is undefined) TypeError: o.replace is not a function. (In 'o.replace(/\;([^\s\;]*?(?=\=))/gi, ",$1")', 'o.replace' is undefined) https://usr//app-service.js:6805:74 [native code] h@https://lib/WAServiceMainContext.js:1:41822 anonymous@[native code] https://usr//app-service.js:6806:39 https://lib/WAServiceMainContext.js:1:1120367 p@https://lib/WAServiceMainContext.js:1:399934 Cc@https://lib/WAServiceMainContext.js:1:873443 https://lib/WAServiceMainContext.js:1:1026394 p@https://lib/WAServiceMainContext.js:1:399934 Wh@https://lib/WAServiceMainContext.js:1:966481 forEach@[native code] emit@https://lib/WAServiceMainContext.js:1:967122 c@https://lib/WAServiceMainContext.js:1:1027541 t_@https://lib/WAServiceMainContext.js:1:1028821 https://lib/WAServiceMainContext.js:1:1029406 https://lib/WAServiceMainContext.js:1:855581 https://lib/WAServiceMainContext.js:1:846662 emit@https://lib/WAServiceMainContext.js:1:356120 emit@[native code] emit@https://lib/WAServiceMainContext.js:1:355739 subscribeHandler@https://lib/WAServiceMainContext.js:1:359225 [native code]
01-03我也遇到这个问题了,卡住解决不了了,报同样的错,安卓和模拟器都是好的,感觉和uploadFile函数的filePath参数是wxfile://tmp_xxxx.jpg 本地文件路径有关系。 楼主最终咋解决的?求助哈,求分享出来吧@子君
在iOS设备中调用 wx.uploadFile 调用报错?在我的iOS设备上调用wx.uploadFile接口报以下错误: "MiniProgramError\nr.replace is not a function. (In 'r.replace(/\;([^\s\;]*?(?=\=))/gi,",$1")', 'r.replace' is undefined)\nTypeError: r.replace is not a function. (In 'r.replace(/\;([^\s\;]*?(?=\=))/gi,",$1")', 'r.replace' is undefined)\nat replace (miniprogram_npm/weapp-cookie/index.js:2414:45)\nat (WAServiceMainContext.js:1:2473449)\nat YX (WAServiceMainContext.js:1:2258626)\nat success (WAServiceMainContext.js:1:2260733)\nat <api uploadFile success callback function>\nat c (WAServiceMainContext.js:1:801289)\nat (WAServiceMainContext.js:1:616788)\nat <NetworkUpload1success callback function>\nat (WAServiceMainContext.js:1:746326)\nat forEach (native code)\nat emit (WAServiceMainContext.js:1:746249)\nat W (WAServiceMainContext.js:1:617843)\nat (WAServiceMainContext.js:1:619289)\nat (WAServiceMainContext.js:1:781469)\nat emit (WAServiceMainContext.js:1:81766)\nat (WAServiceMainContext.js:1:84248)\nat emit (WAServiceMainContext.js:1:81389)\nat subscribeHandler (WAServiceMainContext.js:1:83949)\nglobal code" 设备:iPhone Xs 14.8 [图片][图片]
01-03