I want to know can we simplify the use of data and method here so we don't need to define it one by one like this? Can we use an iteration or other ways?
export default {
data() {
return {
key1 = false,
key2 = false,
key3 = false,
.....
}
},
methods:{
onClick1 () {
key1 = true
},
onClick2 () {
key2 = true
},
onClick3 () {
key2 = true
},
.....
},
.....
}
On the component
<myComp @click="onClick1">One</myComp>
<myComp @click="onClick2">Two</myComp>
<myComp @click="onClick3">Three</myComp>
.....
Any help would be very helpful, thanks in advance!