修复选项为空时的异常

This commit is contained in:
orangej 2022-06-18 18:28:00 +08:00
parent 2e958963ff
commit 8bba9fda23
1 changed files with 4 additions and 2 deletions

View File

@ -42,7 +42,8 @@
watch:{
data(val) {
val.forEach(item => {
this.selected[item.key] = this.selectedValues[item.key] || [item.options[0].value]
this.selected[item.key] = this.selectedValues[item.key] ||
(Array.isArray(item.options) && item.options.length) ? [item.options[0].value] : []
})
}
},
@ -58,7 +59,8 @@
mounted() {
//
this.data.forEach(item => {
this.selected[item.key] = this.selectedValues[item.key] || [item.options[0].value]
this.selected[item.key] = this.selectedValues[item.key] ||
(Array.isArray(item.options) && item.options.length) ? [item.options[0].value] : []
})
},
methods: {