<template>
|
<div>
|
<p v-for="(item, key) in data" :key="key" :class="index === key ? 'active' : ''" @click="handleChange(key)">
|
{{ item }}
|
</p>
|
</div>
|
</template>
|
<script lang="ts" setup name="TheATabs">
|
const props = withDefaults(
|
defineProps<{
|
index: number;
|
data?: Array<any>;
|
}>(),
|
{
|
index: 0,
|
data: () => []
|
}
|
);
|
const emits = defineEmits<{
|
(e: "handleChange", index: number): void;
|
}>();
|
const handleChange = (index: number) => {
|
if (props.index === index) return;
|
emits("handleChange", index);
|
};
|
</script>
|
<style lang="scss" scoped>
|
div {
|
display: flex;
|
align-items: center;
|
padding-bottom: 1px;
|
border-bottom: 2px solid var(--color-bg-5);
|
> p {
|
margin-right: 10px;
|
width: 86px;
|
height: 38px;
|
font-size: 14px;
|
color: var(--color-text-1);
|
line-height: 38px;
|
text-align: center;
|
border-radius: 6px 6px 0px 0px;
|
background: var(--color-bg-2);
|
&.active {
|
background: #1057fd;
|
color: #fff;
|
}
|
cursor: pointer;
|
&:hover {
|
opacity: 0.8;
|
}
|
}
|
}
|
</style>
|