<div class="flex-row product-list">
<div
:class="[
'div-btn',
'flex-row',
isActive === item.value ? 'bg-color' : '',
]"
v-for="item in divBtn"
:key="item.id"
@click="onclick(item)"
>
{{ item.title }}
</div>
</div>
const isActive = ref(1);
const divBtn = reactive([
{
id: 1,
title: "项目管理",
value: 1,
},
{
id: 2,
title: "服务管理",
value: 2,
},
]);
const onclick = (item) => {
// console.log('点击了' + item.title);
isActive.value = item.value;
if (item.title === "项目管理") {
console.log("显示项目管理内容");
score.value = 99;
} else {
score.value = 999;
console.log("显示服务管理内容");
}
};
.bg-color {
background-color: green;
color: white;
}