第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Promise的鏈?zhǔn)秸{(diào)用什么原理?

Promise的鏈?zhǔn)秸{(diào)用什么原理?

海綿寶寶撒 2018-08-23 19:40:24
大家都知道jQuery的鏈?zhǔn)秸{(diào)用是return this的妙用,那么Promise的呢?比如function start() {       return new Promise((resolve, reject) => {         resolve('start');       });     }          start()       .then(data => {         // promise start         console.log('result of start: ', data);         return Promise.resolve(1); // p1       })       .then(data => {         // promise p1         console.log('result of p1: ', data);         return Promise.reject(2); // p2       })       .then(data => {         // promise p2         console.log('result of p2: ', data);         return Promise.resolve(3); // p3       })       .catch(ex => {         // promise p3         console.log('ex: ', ex);         return Promise.resolve(4); // p4       })       .then(data => {         // promise p4         console.log('result of p4: ', data);       });result of start: startresult of p1: 1ex: 2result of p4: 4第三步,reject的還被下一步的then忽略掉了,這種鏈?zhǔn)秸{(diào)用是什么原理?怎么實(shí)現(xiàn)的?
查看完整描述

2 回答

?
蠱毒傳說(shuō)

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊

因?yàn)榘?,每個(gè)then都返回一個(gè)新的promise,每個(gè)then都返回一個(gè)新的promise,每個(gè)then都返回一個(gè)新的promise。
返回的新的promsie會(huì)在上一個(gè)promise的狀態(tài)變更改時(shí)候開(kāi)始執(zhí)行,以此類推,每次返回的新的promise被掛在上一個(gè)promise上,就此串成了一串

查看完整回答
反對(duì) 回復(fù) 2018-08-26
  • 2 回答
  • 0 關(guān)注
  • 1215 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)