后台返回字段way:‘1,2’,
前端根据返回的字段值匹配对应的中文,
const way = '1,2'; // 后台返回的字段way
const groupType = [
{ value: '1', label: '集中学习类' },
{ value: '2', label: '组织生活会类' },
{ value: '3', label: '党性锤炼类' },
{ value: '4', label: '民主议事类' },
{ value: '5', label: '深度融合类' }
];
const matchedGroupTypes = groupType.filter(item => way.includes(item.value));
// 拼接相关字段展示在页面
setFiltersWay (val) {
this.wayStr = ''
val.forEach((item) => {
this.wayStr += item.label + ','
})
// 去除最后一个逗号
if (this.wayStr.length > 0) {
this.wayStr = this.wayStr.substr(0, this.wayStr.length - 1)
}
return this.wayStr
},
根据后端返回数字匹配对应数组对象
最新推荐文章于 2024-05-22 13:52:22 发布