getInfo = (param) => {
const { getData } = this.props // getData为接口请求
return new Promise(resolve => {
getData ({
params: {
param
}
}).then(result => {
if (result.statusCode === 200){
resolve(result.data)
} else {
resolve({})
}
}).catch(() => {
resolve({})
})
})
}
getArrayInfo= () => {
const inputList = [1,2,3,4]
const list = []
inputList.map(item=> {
const temp = this.getInfo(item)
list.push(temp)
})
Promise.all(list).then(res => {
//res为返回的接口数据,数组形式
console.log(res)
})
}