function fun(callback){ Promise.then() .then(() => {}) .then(() => {}) .then(() => {callback()}) .then(() => {}) .then(() => {}) } 一个回调函数包含着一个promise,我想执行到callback就结束,而不执行后面的then,请问有什么优雅的写法么?
回复 (3)
L
function fun(callback){ Promise.then() .then(() => {}) .then(() => {}) .then(() => { callback(); return Promise.reject(); }) .then(() => {}) .then(() => {}) }
这样可以么?
I
可以
I
这样,也许是个方案
const P = Promise.resolve(1)
const M = Promise.resolve(1)
async function fun(callback){
await P.then()
return callback
await M.then()
return 111
}
参与回复
登录后即可参与回复。登录