File size: 838 Bytes
77b0e0f |
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 |
<script setup lang="ts">
import { useRoute, useRouter, type RouteRecordNormalized, type RouteLocationRaw } from 'vue-router'
const route = useRoute()
const router = useRouter()
const handleLink = (item: RouteRecordNormalized) => {
const { redirect, name, path } = item
if (redirect) {
router.push(redirect as RouteLocationRaw)
} else {
if (name) {
router.push({ name })
} else {
router.push({ path })
}
}
}
</script>
<template>
<el-breadcrumb separator="/">
<el-breadcrumb-item
v-for="(item, index) in route.matched"
:key="index"
:to="{ path: item.path }"
>
<a @click.prevent="handleLink(item)">
{{ item.meta.title }}
</a>
</el-breadcrumb-item>
</el-breadcrumb>
</template>
<style lang="scss" scoped></style>
|