方法1:
typeMap: {
"设计": "0",
"商务": "1",
"供货": "2",
"施工": "3",
"调试": "4",
},
checkedLabels: ["设计", "商务", "供货"],
checkedLabels:[]
this.checkedLabels.forEach(label=>{this.applyType.push(this.typeMap[label]})
方法2:
const typeList = "0:设计进度,1:商务采购,2:供货进度,3:施工进度,4:调试进度";
const typeMap = typeList.split(",").reduce((acc, cur) => {
const [key, value] = cur.split(":");
acc[value] = key;
return acc;
}, {});
执行结束后,typeMap 将是一个对象{
"设计": "0",
"商务": "1",
"供货": "2",
"施工": "3",
"调试": "4"
}
this.checkedLabels.forEach((label) => {
const type = typeMap[label];
this.applyType.push(type);
});
11-25
544
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-08
97
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交