js es6 promise 中 resolve 如何传递多个参数?
2021-01-23 19:14
标签:tps let mooc OLE ref eject end ash lan js es6 promise 中 resolve 如何传递多个参数? resolve() 只能接受并处理一个参数,多余的参数会被忽略掉。 数组 对象 参考: js es6 promise 中 resolve 如何传递多个参数? 标签:tps let mooc OLE ref eject end ash lan 原文地址:https://www.cnblogs.com/that-jay/p/13276916.html//我希望类似与这样使用,但实际上后面两个参数无法获取
promise = new Promise((resolve,reject)=>{
let a = 1
let b = 2
let c = 3
resolve(a,b,c)
})
promise.then((a,b,c)=>{
console.log(a,b,c)
})
如果想多个用数组,或者对象方式。。promise = new Promise((resolve,reject)=>{
resolve([1,2,3])
})
promise.then((arr)=>{
console.log(arr[0],arr[1],arr[2])
})
promise = new Promise((resolve,reject)=>{
resolve({a:1,b:2,c:3})
})
promise.then(obj=>{
console.log(obj.a,obj.b,obj.c)
})
https://m.imooc.com/wenda/detail/511405
https://segmentfault.com/q/1010000012800392
文章标题:js es6 promise 中 resolve 如何传递多个参数?
文章链接:http://soscw.com/index.php/essay/45995.html