Array of checkbox values in Vue
Let's say we have a group checkbox
. We can make it so that the value of the attributes value
of all checked checkboxes is added to an array. To do this, we need to bind an array to the v-model
of these checkbox
. Let's do this. Declare a property with an array:
data() {
return {
arr: [],
}
}
Let's bind this array to the checkbox
group:
<template>
<input type="checkbox" v-model="arr" value="v1">
<input type="checkbox" v-model="arr" value="v2">
<input type="checkbox" v-model="arr" value="v3">
</template>
Use several checkbox
to ask the user what languages they know. Add the resulting values to an array.
Print the array of languages obtained in the previous problem as a list ul
.