zhangnuoyan
2024-08-25 77e5c96577bfe426e4a341361e5c196dd5c5b7c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<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>