使用了一个方法:
Promise.all(setTagList) . catch (err => { console.log( '出现了错误诶!!!! => ' , err) }) .finally(() => { const msgBody = { event: { event_type: 'ENTER' } } console.log( 'come into finally' ) that.sendMsg(msgBody, 'enter' ) }) |
这个代码在安卓机器以及开发工具上都表现良好,在线上环境发现IOS的机器稳定出现问题,经过排查发现:
表现行为不一致,要么安卓和IOS都不可行,要么都可行
Promise.prototype.finally = function (callback) {
let P = this.constructor;
return this.then(
value => P.resolve(callback()).then(() => value),
reason => P.resolve(callback()).then(() => { throw reason })
);
};
Promise.all(setTagList).then(res=>{}, fail=>{}).finally(()=>{})
catch的话,放到new Promise()里吧
new Promise(function (resolve, reject) {
try{
****
resolve(b);
} catch (e) {
reject(e);
}
})