Check out example 2 at https://bootstrap-vue.js.org/docs/components/form-checkbox/
Checkboxes – selected values (in this case the user's id) will be elements of the selected array because it's the v-model for the checkbox group. If a user id isn't in the array, it's not selected.
<b-form-group label="Users:">
<b-form-checkbox-group id="checkbox-group" v-model="selected" name="selectedUsers">
<b-form-checkbox v-for="(user, index) in users" :value="user.id" switch></b-form-checkbox>
</b-form-checkbox-group>
</b-form-group>
Your component JS – there are a million ways to find out if a user is selected, below is an example method to see if a specific user id exists in the selected array.
data(){
return {
selected: []
}
},
methods: {
userIsSelected(userid){
return this.selected.includes(userid)
}
}
If you want to know when selection changes, you can watch the selected array:
data(){
return {
selected: []
}
},
watch: {
selected: {
deep: true,
handler: function(newValue){
console.log("Selected users changed", newValue)
}
}
},
methods: {
userIsSelected(userid){
return this.selected.includes(userid)
}
}
The deep property may or may not be necessary, but if your array ever includes objects or nested arrays it would be important.