Answer the question
In order to leave comments, you need to log in
How to select checkboxes by clicking on vue.js?
Here is an example on pure js:
https://codepen.io/anon/pen/xjroxX?editors=0010
How can I do this in vue, or how can I implement something similar using vue?
I know about v-model, but checkboxes are created in a cycle, and it seems to me that generating a model for each is not an option.
Answer the question
In order to leave comments, you need to log in
How can I screw this thing into vue, or how can I implement something similar using vue?
methods: {
onMouseOver(e) {
if (e.buttons) {
e.target.checked = !e.target.checked;
}
},
},
<input
type="checkbox"
v-for="i in 3000"
@mouseover="onMouseOver"
>
for each, it seems to me that it is not an option to generate a model
data: () => ({
checkboxes: Array(3000).fill(false),
}),
methods: {
onMouseOver(e, index) {
if (e.buttons) {
this.$set(this.checkboxes, index, !this.checkboxes[index]);
}
},
},
<input
type="checkbox"
v-for="(n, i) in checkboxes"
v-model="checkboxes[i]"
@mouseover="onMouseOver($event, i)"
>
v-model
(if there are a lot of checkboxes).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question