<div
v-for="(item, index) in dataTimes"
:key="index"
@click="onclick(item, index)"
:class="isActive == index ? 'bg-img' : ''"
>
{{ item.name }}
</div>
const isActive = ref("");
const onclick = (item, index) => {
if (item.name === "小时") {
data.value = "1";
isActive.value = 0;
}
if (item.name === "天") {
data.value = "2";
isActive.value = 1;
}
if (item.name === "月") {
data.value = "3";
isActive.value = 2;
}
};
.bg-img {
background-image: url("/imgs/18.png");
background-size: cover;
background-repeat: no-repeat;
}