fetch('xxxurl.com').then(res=>{
if(res.status === 'ok') {
console.log('我应该如何跳出,不执行下一个then?');
} else {
return 'ok,可以继续';
}
}).then(res=>{
console.log(res);
});我希望根据状态来判断是否要执行接下来的then,应该怎么做?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这样算不算一种方式:
fetch('1.png') .then(function(){ console.log(arguments); throw new Error('test'); }) .then(function(){ console.log('end') }) .catch(function(exc){ console.log(exc); });