I use an array ['one', 'two', 'three']
to create combo box and binding with v-model selectValue
, and then add watcher on that v-model to check all the checkbox when the user deselects all options
watch: {
selectValue(newVal) {
if(newVal.length===0)
this.selectValue = ['one', 'two', 'three']
}
}
When I log the value out. It shows that the selectValue
value contains three values ['one', 'two', 'three']
, but in UI the last deselect checkbox not being checked, but when I wrap around the assign statement with setTimeout
it works (without time out).
Is there any other options to do this. Should I use setTimeout
like current?
this.$set(this, 'selectValue', ['one', 'two', 'three'])
in place ofthis.selectValue = ['one', 'two', 'three']
– Shivam Singh