fix: 修复导航条路由未定义的问题

This commit is contained in:
悠静萝莉 2024-09-04 01:17:47 +08:00
parent e69c4ed98c
commit 0e9ff15f67
No known key found for this signature in database
GPG Key ID: 4EDF1CA1CEA8EBCC

View File

@ -12,13 +12,13 @@ import { useRoute } from 'vue-router';
import { RouteMeta } from '@/types/interface'; import { RouteMeta } from '@/types/interface';
const crumbs = computed(() => { const route = useRoute();
const route = useRoute();
const crumbs = computed(() => {
const pathArray = route.path.split('/'); const pathArray = route.path.split('/');
pathArray.shift(); pathArray.shift();
const breadcrumbs = pathArray.reduce((breadcrumbArray, path, idx) => { return pathArray.reduce((breadcrumbArray, path, idx) => {
// hiddenBreadcrumb // hiddenBreadcrumb
const meta = route.matched[idx]?.meta as RouteMeta; const meta = route.matched[idx]?.meta as RouteMeta;
if (meta?.hiddenBreadcrumb || Object.values(route.params).includes(path)) { if (meta?.hiddenBreadcrumb || Object.values(route.params).includes(path)) {
@ -32,7 +32,6 @@ const crumbs = computed(() => {
}); });
return breadcrumbArray; return breadcrumbArray;
}, []); }, []);
return breadcrumbs;
}); });
</script> </script>
<style scoped> <style scoped>