resolve和reject是两个回调函数,调用resolve会触发then,reject会触发catch
<script>
new Promise((resolve, reject) =>{
setTimeout(() =>{
//成功的时候调用resolve
resolve('成功data')
//失败的时候调用reject
reject('error message')
}, 1000)
}).then((data) =>{
//处理成功后的逻辑
console.log(data);//这个data 是接收的resolve参数--
}).catch((err) =>{
console.log(err);
})
</script>
标签:调用,console,如何,resolve,Promise,reject,data
From: https://www.cnblogs.com/linhan8888/p/16977738.html