vue3使用Promise.all配合async/await使用
备注:我这里用的vue3//请求一const one = async() => {let params = {}const res = await $http(params)return res}//请求二const two = async() => {let params = {}const res = await $http(params)return res}//promise.
·
备注:我这里用的vue3
//请求一
const one = async() => {
let params = {}
const res = await $http(params)
return res
}
//请求二
const two = async() => {
let params = {}
const res = await $http(params)
return res
}
//promise.all()来使他们并行请求
const total = async() => {
const res = await Promise.all([one(),two()])
console.log('请求1',res[0])
console.log('请求2',res[1])
}
成功!
更多推荐
已为社区贡献31条内容
所有评论(0)