This commit is contained in:
pengxiaolong
2025-07-02 15:01:23 +08:00
parent ec8bffa6f0
commit b2346c856a
6 changed files with 102 additions and 72 deletions

View File

@@ -70,7 +70,7 @@
<!-- 顶部 -->
<el-header class="header">
<el-breadcrumb :separator-icon="ArrowRight">
<el-breadcrumb-item :to="{ path: '/nav/Home' }">首页</el-breadcrumb-item>
<el-breadcrumb-item :to="{ path: '/nav/Home' }" @click="onBreadcrumbClick('/nav/Home')">首页</el-breadcrumb-item>
<el-breadcrumb-item
v-for="(item, index) in breadcrumbList"
:key="index"
@@ -129,7 +129,6 @@ function convertPathsToMenuItems(paths) {
}
//面包屑
function handleSelect(index, indexPath) {
console.log("select", convertPathsToMenuItems(indexPath));
breadcrumbList.value = convertPathsToMenuItems(indexPath);
}
//面包屑地址判断
@@ -140,6 +139,17 @@ function handleurl(indexPath) {
return indexPath;
}
}
//处理面包屑点击事件
function getPreviousObjects(arr, targetPath) {
// 找到匹配目标路径的第一个元素的索引
const index = arr.findIndex(item => item.path === targetPath);
// 如果找到匹配项,则返回从开始到该索引的子数组(包含自身)
return index !== -1 ? arr.slice(0, index + 1) : [];
}
function onBreadcrumbClick(path) {
breadcrumbList.value = getPreviousObjects(breadcrumbList.value, path)
}
//菜单展开
function toggleCollapse() {
asideWidth.value = isCollapse.value ? "10vw" : "4vw";