This is a basic vue.js project where I have added a button on the page. When the button is clicked, the showProduct property is set to either true or false. The html part is as below
<div id="app">
<button v-on:click="showCheckout">Click Me</button>
</div>
The Vue object is as follows
<script>
const store = new Vue({
el: '#app',
data: {
showProduct:true,
},
methods: {
showCheckout: function() {
this.showProduct = this.showProduct ? false: true;
}
}
});
</script>
Problem: The property is not updated when the button is clicked. I have tried to use return this.showProduct = this.showProduct ? false: true;
but the issue remained unsolved.
If I open the Vue dev tools and in the Components tab I click the Root component the value changes once. If the button is clicked again several times the value does not change. It only changes when I first click the button on the page and then click the Root component in dev tools. If the root Root component is clicked twice, the value does not change.