promise和async取消的办法:return 一个空的promise
直接return 一个false是没有效果的
async fn1() {
await articleItems().then(res => {return false})
await articleItems().then(res => {console.log(3)})
console.log(4)
}
//3,4
这是在async的情况下,证明有效
async fn1() {
await articleItems().then(res=>{console.log(1); return new Promise(() => {})}).then(res=>articleItems().then(res => {console.log(5)}))
await articleItems().then(res => {return false})
await articleItems().then(res => {console.log(3)})
console.log(4)
}
//1
这是在promise的情况下,证明有效
articleItems().then(res => {
if (true) {
console.log(1)
return new Promise(() => {});
}
}).then(res => {
console.log("2res");
});
//1,res