gpt4 book ai didi

javascript - 如何使用Vue的Ant Design Pro调整面包屑的正确级别?

转载 作者:行者123 更新时间:2023-12-02 23:27:33 30 4
gpt4 key购买 nike

我尝试修改路由配置问题,但是面包屑有两个相同的用户列表,错误显示为首页/系统设置/用户列表/用户列表。例如,当左侧菜单点击用户列表时,应该正确显示首页/系统设置/用户列表

错误显示为:

enter image description here

正确显示为:

enter image description here

router.config.js

{
path: '/settings',
name: 'settings',
component: RouteView,
redirect: '/settings/user',
meta: { title: '设置系统', keepAlive: true, icon: bxAnaalyse },
children: [
{
path: '/settings/user',
name: 'user',
component: RouteView,
redirect: '/settings/user/list',
meta: { title: '用户列表', keepAlive: false },
hideChildrenInMenu: true,
children: [
{
path: '/settings/user/list',
name: 'user',
component: () => import('@/views/settings/user/index'),
meta: { title: '用户列表', keepAlive: false }
},
{
path: '/settings/user/add',
name: 'add',
component: () => import('@/views/settings/user/add'),
meta: { title: '新增用户', keepAlive: true, hidden: true }
}
]
},

]
},

组件/工具/Breadcrumb.vue

<template>
<a-breadcrumb class="breadcrumb">
<a-breadcrumb-item v-for="(item, index) in breadList" :key="item.name">

<router-link
v-if="item.name != name && index != 1"
:to="{ path: item.path === '' ? '/' : item.path }"
>{{ item.meta.title }}
</router-link>

<span v-else>{{ item.meta.title }}</span>
</a-breadcrumb-item>
</a-breadcrumb>
</template>

<script>
export default {
data () {
return {
name: '',
breadList: []
}
},
created () {
this.getBreadcrumb()
},
methods: {
getBreadcrumb () {
this.breadList = []
// this.breadList.push({name: 'index', path: '/', meta: {title: '首页'}})

this.name = this.$route.name
this.$route.matched.forEach(item => {
// item.name !== 'index' && this.breadList.push(item)
this.breadList.push(item)
})
}
},
watch: {
$route () {
this.getBreadcrumb()
}
}
}
</script>

<style scoped>
</style>

最佳答案

为什么要将“/settings/user”重定向到“/settings/user/list”?额外的“用户列表” 面包屑中的来自“/settings/user/list”的标题。我建议您删除“/settings/user/list”项和“/settings/user”的“redirect”属性。

关于javascript - 如何使用Vue的Ant Design Pro调整面包屑的正确级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56671603/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com