页面顶部的横向页签,激活项字号加粗并带一条短下划线;窄屏时导航区可横向滚动。右侧默认插槽常放操作按钮。
使用 v-model 绑定当前页签 key,右侧放了一个操作按钮。
<script setup lang="ts">
import { ref } from 'vue';
import { KHeaderTabs } from '@wujies/components';
const active = ref('detail');
const tabs = [
{ key: 'detail', label: '详情' },
{ key: 'records', label: '操作记录' },
{ key: 'setting', label: '权限设置' }
];
</script>
<template>
<div>
<KHeaderTabs v-model="active" :tabs="tabs">
<el-button size="small">右侧操作</el-button>
</KHeaderTabs>
<div style="margin-top: 20px; padding: 16px; background: var(--el-fill-color-light); border-radius: 6px">
当前页签:<strong>{{ active }}</strong>
</div>
</div>
</template>
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| modelValue | 当前页签 key,支持 v-model | string | 必填 |
| tabs | 页签列表 { key, label } | KHeaderTab[] | 必填 |
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| update:modelValue | 页签切换 | 新的 key |
| 插槽名 | 说明 |
|---|---|
| default | 页签右侧的额外区域 |