The next element is a single checkbox <input> element that will hold the default Boolean value:
// src/components/basic.vue
<label class="label">Subscribe</label>
<input type="checkbox" v-model="form.subscribe">
export default {
data () {
return {
form: { subscribe: false }
}
},
methods:{
checkForm (e) {
this.errors = []
if (!this.form.subscribe) {
this.errors.push('Subscription required')
}
}
}
}
We also will add the following multiple checkbox <input> elements that are bound to the same array, that is, books: []:
// src/components/basic.vue
<input type="checkbox" v-model="form.books" value="On the Origin of Species">
<label for="On the Origin of Species">On the Origin of Species</label>
<input type="checkbox" v-model="form.books" value="A Brief History of Time"...