一、value反显为label
getLabel (list, value) {
if (list && list.length > 0 && value) {
const form = list.find((item) => item.value === value)
return form ? form.label : value
} else {
return ''
}
}
二、value组成的字符串反显为label
const wayOpt = [
{ label: '线上', value: '0' },
{ label: '线下', value: '1' }
]
form.way = '0, 1'
from.wayName = this.getStringName(from.way, wayOpt,'value')
getStringName (string, list, key) {
if (string) {
const splitList = string.split(',')
const name = []
splitList.forEach((item) => {
list.forEach((l) => {
if (item === l[key]) {
name.push(l.label)
}
})
})
return name.join(',')
} else {
return ''
}
}
1250

被折叠的 条评论
为什么被折叠?



