As in the title:
<li v-for="item in artistsList">
<img :src="item.user_avatar" alt="">
<p>
<p>{{item.user_name}}</p>
<span>{{item.user_job}}/{{item.user_country}}</span>
</p>
<label>
<input type="checkbox" :value="item.user_id" v-model="userID">
</label>
</li>
data () {
return {
userID:[],
artistsList:[]
}
},
When artistsList is mounted, it will load the data and generate the list by itself, but if you want it to be in the checked state when input is generated, what should you do?
It works if userID is set to true, but when I click on any of the checkboxes, all operations will be performed, similar to selecting all and canceling all selections.
My requirements are as follows:
1. It is selected by default when generating
2. When I select and operate any checkbox, the userId data in the data will be dynamically updated. Let’s talk about what friends do
v-model="item.userID" will do,
item.userID is a Boolean value