I have three buttons, I want to do this when you click on it, the background changed, for example, when you click on the red button, the background color changed to red, but here there is one important nuance if you click, for example, on the red button, and then another button, then the old color should disappear
For example, I clicked on the orange button, the background of the button turned orange, and then I clicked on the green button, then the orange background should disappear, You can also look at the code in codesandbox
<template>
<div>
<div v-for="(btn, index) in buttonCheckAge" :key="index" class="select-age">
<div>
<p>{{ btn.btnName }}</p>
</div>
<div>
<button :class="btn.className">{{ btn.btnText }}</button>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
buttonCheckAge: [
{
btnName: "Blue",
btnText: "btn-Blue",
className: "btn-teens",
state: 0,
},
{
btnName: "Red",
btnText: "btn-Red",
className: "btn-minxes",
state: 1,
},
{
btnName: "Green",
btnText: "btn-Green",
className: "btn-milfs",
state: 2,
},
],
};
},
};
</script>