下面是一個簡單的promise調(diào)用new Promise(function(success,){
setTimeout(function(){success()},1000);
}).then(function(){
console.log(1)
});可以看到,控制臺能夠輸出1Promise 的then方法可以做到回調(diào)功能,但是如果是這種情況呢?function test(back){
setInterval(function(){back()},1000)
}
test(function(){
console.log(1);
});//可以不停的輸出1而如果用promise做不到:new Promise(function(success,){
setInterval(function(){success()},1000);
}).then(function(){
console.log(1)
});Promise 除了then,catch還有隱藏的高級功能么?
怎么解決promise只執(zhí)行一次的問題
梵蒂岡之花
2018-09-30 11:07:34
