0👍
A button
has no value
… But you could use a data attribute like this:
<div class="123">
<button id = "Abutton" @click="abutton()" data-clickcount="0">
<img src="randomimage.png"
style="width: 30px; height: 30px;"
/>
</button>
</div>
And in Vue.js:
abutton: function (e) {
// Get the count
const ButtonVal = +(e.target.dataset.clickcount);
// Increment and store it
e.target.dataset.clickcount = ButtonVal++;
// log it
console.log("Number of likes:" + ButtonVal)
},
- [Vuejs]-Vue3 Copy Router Path to Clipboard with User Data
- [Vuejs]-Vue Reactivity, How to Improve nested component dependency structure
Source:stackexchange.com