43 lines
1.0 KiB
Vue
43 lines
1.0 KiB
Vue
<template>
|
|
<el-breadcrumb class="app-breadcrumb">
|
|
<el-breadcrumb-item v-for="item in breadcrumbs" :key="item.path">
|
|
{{ item.meta.title }}
|
|
</el-breadcrumb-item>
|
|
</el-breadcrumb>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import type { RouteLocationMatched, RouteLocationNormalizedLoaded } from 'vue-router'
|
|
|
|
import { useWatchRoute } from '@/hooks/useWatchRoute'
|
|
|
|
const breadcrumbs = ref<RouteLocationMatched[]>([])
|
|
const getBreadcrumb = (route: RouteLocationNormalizedLoaded) => {
|
|
const matched = route.matched.filter((item) => item.meta && item.meta.title)
|
|
breadcrumbs.value = matched
|
|
}
|
|
|
|
useWatchRoute((route) => {
|
|
getBreadcrumb(route)
|
|
})
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
.app-breadcrumb {
|
|
:deep(.el-breadcrumb__item) {
|
|
.el-breadcrumb__inner {
|
|
color: #303133;
|
|
font-weight: 500;
|
|
}
|
|
|
|
&:last-child .el-breadcrumb__inner {
|
|
color: #303133;
|
|
}
|
|
}
|
|
|
|
:deep(.el-breadcrumb__separator) {
|
|
color: #606266;
|
|
}
|
|
}
|
|
</style>
|