Answer the question
In order to leave comments, you need to log in
How to make the checkbox already pre-clicked?
Good afternoon, there is a code example jsfiddle.net/bmpfs2w2 , how to make the checkbox when loading the page was immediately clicked and the value was immediately transferred? thanks in advance)
Answer the question
In order to leave comments, you need to log in
data: () => ({
mainCategories: [
{ merchantId: '1', checked: true },
{ merchantId: '2', checked: true },
...
],
}),
computed: {
checkedCategories() {
return this.mainCategories.filter(n => n.checked).map(n => n.merchantId);
},
},
<li v-for="n in mainCategories">
<label>
<input type="checkbox" v-model="n.checked">
{{ n.merchantId }}
</label>
</li>
created() {
this.checkedCategories = this.mainCategories.map(n => n.merchantId);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question