I am currently working on a simple code snippet that updates a counter each time a specific button is clicked. The counter restarts once it reaches 3 and the number is displayed on each button. Everything seems to be functioning correctly, but I have come across a strange issue - if the first button does not start at 0, clicking any other button will reset the first button's value back to 0. Could this suggest that the buttons are somehow connected?
new Vue({
el: "#app",
data: {
one: 0,
two: 0,
three: 0
},
methods: {
chooseOne: function(x, y) {
if ((x == 1) && (this.one < 3)) {
this.one++;
} else {
this.one = 0
}
if (x == 2) {
if ((x == 2) && (this.two < 3)) {
this.two++;
} else {
this.two = 0
}
}
if (x == 3) {
if ((x == 3) && (this.three < 3)) {
this.three++
} else {
this.three = 0
}
}
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<button @click="chooseOne(1,one)">
{{ one }}
</button>
<button @click="chooseOne(2,two)">
{{ two }}
</button>
<button @click="chooseOne(3,three)">
{{ three }}
</button>
</div>