ant-design-vue/components/breadcrumb/demo/router.vue
Cherry7 9be58078d2
Refactor(demo): change options to composition api (#6499)
* feat(demo): A-B

* feat(demo): update B-checkbox

* feat(demo): update CheckBox -DatePicker

* feat(demo): update DatePicker - Form

* feat(demo): update Form - List

* feat(demo): update  List-pagination

* feat(demo): update  List - skeleton

* feat(demo): update  skeleton - switch

* feat(demo): update  skeleton - switch

* feat(demo): update   switch - upload

* feat(demo): update  watermark

* fix(demo): del hashId
2023-04-28 14:08:21 +08:00

75 lines
1.3 KiB
Vue

<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>