其他分享
首页 > 其他分享> > Vue前端树形菜单面包屑递归

Vue前端树形菜单面包屑递归

作者:互联网

Vue前端树形菜单面包屑递归

1.递归菜单

  findIndexArray(data, id, indexArray) {
    let arr = Array.from(indexArray);
    for (let i = 0, len = data.length; i < len; i++) {
      arr.push(data[i]);
      if (data[i].id === id) {
        return arr;
      }
      let children = data[i].childMenu;
      if (children && children.length) {
        let result = this.findIndexArray(children, id, arr);
        if (result) {
          return result;
        }
      }
      arr.pop();
    }
  },

2.elementUI 面包屑显示

   <el-breadcrumb separator-class="el-icon-arrow-right" class="breadClass">
     <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
     <el-breadcrumb-item  v-for=" breadcrumb in breadcrumbs" >{{breadcrumb.menuname}}</el-breadcrumb-item>
   </el-breadcrumb>

效果图:
在这里插入图片描述

标签:arr,Vue,id,树形,let,result,面包屑,data,children
来源: https://blog.csdn.net/HuanFengZhiQiu/article/details/113527200