Promise.finally
const Gen = (time) => { return new Promise((resolve, reject) => { setTimeout(function () { if(time < 500) { reject(time) } else { resolve(time) } },time) }) } Gen(Math.random() * 1000) .then(val => console.log('resolve', val)) .catch(err => console.log('reject', err)) .finally(() => { console.log('finish')})
版权声明:本文为qjb2404原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。