mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* 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>
48 lines
892 B
Vue
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>
|