uni-app 内部addInterceptor returnValue报错 TypeError: Cannot read property '0' of undefined

uni-app 内部addInterceptor returnValue报错 TypeError: Cannot read property ‘0’ of undefined

操作步骤:

调试基础库大于 2.29.2 都会出现

预期结果:

调试基础库大于 2.29.2 都会出现

实际结果:

Promise {<pending>}
catch: (...)
constructor: (...)
finally: (...)
hasOwnProperty: (...)
isPrototypeOf: (...)
propertyIsEnumerable: (...)
then: (...)
toLocaleString: (...)
toString: (...)
valueOf: (...)
Symbol(Symbol.toStringTag): (...)
__defineGetter__: (...)
__defineSetter__: (...)
__lookupGetter__: (...)
__lookupSetter__: (...)
__proto__: Object
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: undefined

bug描述:

内部addInterceptor returnValue报错 WAServiceMainContext.js?t=wechat&s=1723431397928&v=3.5.3:1 TypeError: Cannot read property ‘0’ of undefined

Image


更多关于uni-app 内部addInterceptor returnValue报错 TypeError: Cannot read property '0' of undefined的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复

你好,提供一下复现的demo代码或者demo工程

更多关于uni-app 内部addInterceptor returnValue报错 TypeError: Cannot read property '0' of undefined的实战教程也可以访问 https://www.itying.com/category-93-b0.html


demo已经提交,管理员可见

已确认bug,感谢反馈,已加分

你好,可以临时兼容修复一下,这个后面版本优化, 临时修复方式 将uni.promisify.adaptor.js 里面的res做一个判断
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === “object” || typeof res === “function”) && typeof res.then === “function”)) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
});
// 替换为
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === “object” || typeof res === “function”) && typeof res.then === “function”)) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => {
if (!res) return resolve()
return res[0] ? reject(res[0]) : resolve(res[1])
});
});
},
});

好的,感谢

版本已修复 4.26.2024082213-alpha

回到顶部