1.项目背景
在实际项目中,查询条件中可能有存在多个下拉选择框,其中枚举数据为后端接口获取,而不是前端写死;可以使用Promise.all([])
获取多个枚举数据;
2.代码示例
2.1 data中定义
在data
中定义数据类型;
示例:
data() {
return {
list1: [],
list2: [],
list3: [],
}
}
2.2 项目示例代码
示例:
const [
list1_1,
list2_2,
list3_3,
] = await Promise.all([
getValues('name-1', false, '服务'),
getValues('name-2', false, '服务'),
getValues('name-3', false, '服务'),
])
this.list1 = list1_1
this.list2 = list2_2
this.list3 = list3_3