标签:highlight eject javascrip catch new span color promise nbsp
promise.then 如果不加第二个参数则会执行catch方法, 加第二个参数则不会执行catch方法。
var pro=new Promise((resolve,reject)=>{ // resolve(); reject(); }) pro.then(()=>{ console.log(‘resolve1‘); }).catch(()=>{ console.log(‘catch1‘) })
var pro=new Promise((resolve,reject)=>{ reject(); resolve(); }) pro.then(()=>{ console.log(‘resolve1‘); },()=>{console.log(‘reject1‘)}).catch(()=>{ console.log(‘catch1‘) })
标签:highlight eject javascrip catch new span color promise nbsp
原文地址:https://www.cnblogs.com/xiaoyaoweb/p/14776289.html