forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.vue
74 lines (70 loc) · 1.35 KB
/
router.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<docs>
---
order: 3
iframe: 200
reactRouter: react-router-dom
title:
zh-CN: 其它路由
en-US: Other Router Integration
---
## zh-CN
和 `vue-router` 进行结合使用。
## en-US
Used together with `vue-router`
</docs>
<template>
<div>
<a-breadcrumb :routes="routes">
<template #itemRender="{ route, paths }">
<span v-if="routes.indexOf(route) === routes.length - 1">
{{ route.breadcrumbName }}
</span>
<router-link v-else :to="`${basePath}/${paths.join('/')}`">
{{ route.breadcrumbName }}
</router-link>
</template>
</a-breadcrumb>
<br />
{{ $route.path }}
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
interface Route {
path: string;
breadcrumbName: string;
children?: Array<{
path: string;
breadcrumbName: string;
}>;
}
const basePath = '/components/breadcrumb';
const routes = ref<Route[]>([
{
path: 'index',
breadcrumbName: 'home',
},
{
path: 'first',
breadcrumbName: 'first',
children: [
{
path: '/general',
breadcrumbName: 'General',
},
{
path: '/layout',
breadcrumbName: 'Layout',
},
{
path: '/navigation',
breadcrumbName: 'Navigation',
},
],
},
{
path: 'second',
breadcrumbName: 'second',
},
]);
</script>