94 lines
1.8 KiB
Vue
94 lines
1.8 KiB
Vue
<template>
|
||
<div>
|
||
<div class="tabs-container ">
|
||
<div
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'reference' }"
|
||
@click="switchTab('reference')"
|
||
>
|
||
参考生视频
|
||
</div>
|
||
<div
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'image' }"
|
||
@click="switchTab('image')"
|
||
>
|
||
图生视频
|
||
</div>
|
||
<div
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'text' }"
|
||
@click="switchTab('text')"
|
||
>
|
||
文生视频
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang='ts'>
|
||
// 定义 Tab 类型,与父组件保持一致
|
||
type TabType = 'reference' | 'image' | 'text';
|
||
|
||
// 接收父组件传递的 activeTab,使用联合类型
|
||
defineProps<{
|
||
activeTab: TabType;
|
||
}>();
|
||
|
||
// 定义事件,tab 参数同样使用联合类型
|
||
const emit = defineEmits<{
|
||
(e: 'tabChange', tab: TabType): void;
|
||
}>();
|
||
|
||
// 切换 tab
|
||
const switchTab = (tab: TabType) => {
|
||
emit('tabChange', tab);
|
||
};
|
||
</script>
|
||
|
||
<style scoped lang='less'>
|
||
.tabs-container {
|
||
width: 100%;
|
||
height: 44x;
|
||
display: flex;
|
||
background-color: #1a1c20;
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.tab-item {
|
||
width: 50%;
|
||
flex: 1;
|
||
padding: 12px 0;
|
||
background: transparent;
|
||
border: none;
|
||
color: rgba(255, 255, 255, 0.6);
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
cursor: pointer;
|
||
transition: all 0.3s;
|
||
text-align: center;
|
||
position: relative;
|
||
}
|
||
|
||
.tab-item:hover {
|
||
color: #fff;
|
||
background-color: rgba(255, 255, 255, 0.08);
|
||
}
|
||
|
||
.tab-item.active {
|
||
color: #fff;
|
||
background-color: rgba(255, 255, 255, 0.15);
|
||
}
|
||
|
||
.tab-item.active::after {
|
||
content: '';
|
||
position: absolute;
|
||
bottom: 0;
|
||
left: 20%;
|
||
width: 60%;
|
||
height: 2px;
|
||
border-radius: 2px;
|
||
}
|
||
</style> |