代码片段: https://developers.weixin.qq.com/s/4Voj78mf7cbz
const app = getApp() Page({ data: { }, onLoad: function () { Promise.resolve( 'foo' ) .then((res) => console.log(res)) .finally(() => console.log(123)); }, }) |
开发者工具能正常执行
编译后上传预览还是报错。开发运行结果,和真机运行结果还不一致?
试了下安卓可以。。ios不行。。
const app = getApp()
Promise.prototype.finally = function (cb) {
let P = this.constructor;
return this.then(
value => P.resolve(cb()).then(() => value)
);
};
Page({
data: {
},
onLoad: function () {
Promise.resolve('foo')
.then((res) => console.log(res))
.finally(() => console.log(123));
},
})