Skip to content

Commit aebcbd0

Browse files
committed
feat(pro-layout): 测试示例添加PageContainer对tab-list使用测试
1 parent 2b5ad2d commit aebcbd0

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

packages/pro-layout/examples/router/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ const routes: RouteRecordRaw[] = [
104104
},
105105
],
106106
},
107+
{
108+
path: '/test-tab',
109+
name: 'TestTab',
110+
meta: { title: '测试Tab标签', hideInMenu: false },
111+
component: () => import('../views/TestTab.vue'),
112+
},
107113
{
108114
path: 'https://next.antdv.com/',
109115
name: 'baidu_target',
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<template>
2+
<PageContainer
3+
:loading="loading"
4+
fixed-header
5+
:title="(route.meta.title as string)"
6+
:tab-list="tabList"
7+
:tab-active-key="tabActiveKey"
8+
@tab-change="tabChange"
9+
:tabProps="{
10+
hideAdd: true,
11+
tabPosition: 'top',
12+
type: 'editable-card',
13+
tabBarGutter: 8,
14+
tabBarStyle: { margin: '0', height: '32px', lineHeight: '32px' },
15+
onEdit: tabEdit,
16+
}"
17+
>
18+
<template #tags>
19+
<Tag>tag1</Tag>
20+
<Tag color="pink">tag2</Tag>
21+
</template>
22+
<Result
23+
status="info"
24+
:style="{
25+
height: '100%',
26+
}"
27+
title="show tabs"
28+
sub-title="pro-layout可使用 tabRender 插槽自定义标签页"
29+
>
30+
<template #extra>
31+
<Button type="primary">ME {{ tabActiveKey }}</Button>
32+
</template>
33+
</Result>
34+
</PageContainer>
35+
</template>
36+
37+
<script setup lang="ts">
38+
import { Button, Tag, Result } from "ant-design-vue";
39+
import { PageContainer } from "@ant-design-vue/pro-layout";
40+
41+
import { useRoute } from "vue-router";
42+
import { reactive, ref } from "vue";
43+
44+
const route = useRoute();
45+
46+
let loading = ref<boolean>(false)
47+
let tabList = reactive(
48+
Array.from({ length: 54 }, (_, i) => ({ key: "/tab" + i, tab: "tab" + i }))
49+
);
50+
let tabActiveKey = ref("/tab1");
51+
function tabChange(key: string) {
52+
console.log("tabChange", key);
53+
tabActiveKey.value = key;
54+
}
55+
function tabEdit(key: string) {
56+
console.log("tabEdit", key);
57+
loading.value = true
58+
setTimeout(() => {
59+
loading.value = false
60+
}, 2000);
61+
}
62+
</script>

0 commit comments

Comments
 (0)