第一种常规操作

    //洗数据
deep(r): void {

for (let i of r) {
let num = i.type;
switch (num) {
case 0:
i["type_name"] = '首页模块';
break;
case 1:
i["type_name"] = '营销模块';
break;
case 2:
i["type_name"] = '首页头部';
break;
case 3:
i["type_name"] = '首页背景';
break;
default:
i["type_name"] = '首页模块';
}


}
return r
}

第二种操作

 //洗数据
deep(r): void {
const map = {
0: '首页模块',
1: '营销模块',
2: '首页背景',
3: '首页模块',
};
for (let i of r) {
let num = i.type;
i["type_name"] = map[num];
}
return r
}

常规操作

let test={k:123,o:456};
for(let [key,value] of Object.entries(test)){
console.log([key,value]);
}

洗数据
deep(r): void {
const map = {
0: '首页模块',
1: '营销模块',
2: '首页背景',
3: '首页模块',
};
for (let i of r) {
let num = i.type;
i["type_name"] = map[num];
}
return r

switch (num) {
case 0:
i["type_name"] = '首页模块';
break;
case 1:
i["type_name"] = '营销模块';
break;
case 2:
i["type_name"] = '首页头部';
break;
case 3:
i["type_name"] = '首页背景';
break;
default:
i["type_name"] = '首页模块';
}