Files
element-plus/docs/examples/tabs/default-value.vue
云游君 7be439a53a fix(components): [tabs] default-value support and update demo for docs (#22896)
* fix(components): [tabs] default-value support and update demo for docs

* chore: update docs/en-US/component/tabs.md

Co-authored-by: btea <2356281422@qq.com>

* fix(components): [tabs] undefined for defaultValue

---------

Co-authored-by: btea <2356281422@qq.com>
2025-11-23 15:18:51 +08:00

48 lines
892 B
Vue

<template>
<el-tabs
v-model="activeName"
class="demo-tabs"
default-value="third"
@tab-click="handleClick"
>
<el-tab-pane
v-for="tab in tabs"
:key="tab.name"
:label="tab.label"
:name="tab.name"
>
default-value: third
<br />
active: {{ activeName }}
</el-tab-pane>
</el-tabs>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { TabsPaneContext } from 'element-plus'
const tabs = ref([
{ label: 'User', name: 'first' },
{ label: 'Config', name: 'second' },
{ label: 'Role', name: 'third' },
{ label: 'Task', name: 'fourth' },
])
const activeName = ref()
const handleClick = (tab: TabsPaneContext, event: Event) => {
console.log(tab, event)
}
</script>
<style>
.demo-tabs > .el-tabs__content {
padding: 32px;
color: #6b778c;
font-size: 32px;
font-weight: 600;
}
</style>