v-model接收的数据应该是数组,而已数组里的参数必须是number:[0, 1 , 2] 的形式,才能正确显示。
<el-select v-model="edtBox.term_with" :multiple-limit="2" multiple placeholder="请选择" @change="organsChange">
<el-option
v-for="item in organs"
:key="item.term_id"
:label="item.term_name"
:value="item.term_id"
/>
</el-select>
后端返回回来的是字符串所以对数据进行重构,先酱字符串转换为数组,再去遍历,将item的值转换为number,最后重新push。
lookDetail(row) {
if (row.term_with) {
const arr = row.term_with.split(',')
const list = []
arr.map(item => {
list.push(parseInt(item))
})
this.edtBox.term_with = list
} else {
this.edtBox.term_with = ''
}
}