index.vue
1.3 KB
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
<template>
<div class="layout">
<a-breadcrumb>
<a-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="index">
<a v-if="index < breadcrumbList.length - 1" @click="handleBreadcrumbClick(item.query)">{{
item.title
}}</a>
<span v-else>{{ item.title }}</span>
</a-breadcrumb-item>
</a-breadcrumb>
</div>
</template>
<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router';
import { useI18n } from '/@/hooks/web/useI18n';
import { defineProps } from 'vue';
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
// 定义接收父组件传递的面包屑数据的 props
const props = defineProps({
breadcrumbList: {
type: Array as () => Array<{ title: string; query?: string }>,
default: () => [],
},
});
// 处理面包屑点击事件
const handleBreadcrumbClick = (query?: string) => {
if (query) {
router.push({
path: route.path,
query: { type: query },
});
} else {
router.go(-1);
}
};
</script>
<style scoped lang="less">
.layout {
padding: 6px 10px 6px 10px;
margin-bottom: 16px;
background-color: #fff;
font-size: 14px;
.ant-breadcrumb {
height: 46px;
line-height: 46px;
}
}
</style>