Answer the question
In order to leave comments, you need to log in
How to check a checkbox in a nested component through its incoming $event.target?
Has a parent:
<CheckboxComponent
v-model="myDatas"
:value="1"
@click="onCheckbox($event)"
>
// В нем метод:
onCheckbox($event) {
// Тут проверки, если сняты все чекбыксы, то включить последний снятый
$event.target.checked = true;
},
<input
:value="value"
:checked="isChecked"
type="checkbox"
@click="handleClick($event)"
>
// И тут есть метод:
handleClick($event) {
this.$emit('click', $event);
}
Answer the question
In order to leave comments, you need to log in
You don't need to set checked directly, that's not how vue does things.
prevent unchecking the last checkbox
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question