cocos creator promise 原生平台BUG
作者:互联网
1 class NewPromise extends Promise{ 2 constructor(fn){ 3 4 const fn2 = function(resolve, reject) { 5 const reject2 = (err) => { 6 setTimeout(() => {reject(err);}, 0) 7 }; 8 9 try { 10 fn(resolve, reject2); 11 } catch (error) { 12 reject2(error) 13 } 14 } 15 16 17 super(fn2); 18 } 19 } 20 21 window.Promise = NewPromise;
异步异常捕获, 如果不重写,会抛好几个错误。 直接将这个代码设置为插件就OK
标签:cocos,const,fn2,reject2,creator,error,NewPromise,promise,reject 来源: https://www.cnblogs.com/dzqdzq/p/16205228.html