/**
* @description:获取数据
*/
async getDeviceEnumSelect(all) {
let arr = ["string", "int8", "float", "_location", "pic", "document"];
let list = all.map(async item => {
return {
...item,
options:
arr.indexOf(item.dataType) === -1
? await this.getDeviceEnum(item.propertyLabel) //注意一定要是用await
: []
};
});
Promise.all(list)
.then(res => {
let data = res; //最终想要的结果
})
.catch(error => {
console.log(error);
});
},
/**
* @description: 数据接口调用
*/
getDeviceEnum(item) {
let vm = this;
return new Promise(resolve => {
getDeviceEnum(item).then(res => {
resolve(res.data);
});
});
},
promise.all解决循环数组调用接口
最新推荐文章于 2024-08-19 16:57:11 发布