• Vue中面包屑导航功能和实现---面包屑导航--$route.matched


     DOM部分:

    <el-breadcrumb class="breadcrumb" separator="/">
                <el-breadcrumb-item 
                    v-for='(name,index) in matchedArr'
                    :key='index'
                    >
                    {{ $t(`commons.${name}`)}}
                </el-breadcrumb-item>
    </el-breadcrumb>

    script部分:

    computed:{
            matchedArr(){
                let temp = [],temps = [];
                this.$route.matched.filter((item,index,self) => {
                    // if(item.meta.title){
                    //     const title = item.meta.title;
                    //     temp.push(title);
                    // }
                    if(item.name){
                        const name = item.name;
                        temp.push(name);
                    }
                });
                temp.filter((item,index,self) => {
                    if(!temps.includes(item)){
                        temps.push(item);
                    }
                })
                return temps;
            }
    }

     路由文件举例:

    {
        path: "/fundManage",
        name: "fundManage",
        meta: {
          title: "资金管理",
          icon: "iconpay3",
        },
        component: Layout,
        children: [
          {
            path: "fundList",
            name: "fundList",
            meta: {
              title: "资金流水",
              routerType: "leftmenu",
            },
            component: () => import("@/page/fundList/fundList"),
          },
          {
            path: "chinaTabsList",
            name: "chinaTabsList",
            meta: {
              title: "区域投资",
              routerType: "leftmenu",
            },
            component: () => import("@/page/fundList/chinaTabsList"),
          },
        ],
      }

  • 相关阅读:
    c#备忘知识点
    [置顶] IE6支持的滑动菜单栏
    摩斯电碼中英文对照表
    2013年5月15日星期三
    2013年5月9日星期四
    2013年5月12日16:20:43母亲节
    2013年5月8日星期三
    JS前端DOM中Range疑问
    2013年5月14日星期二
    2013年5月13日星期一
  • 原文地址:https://www.cnblogs.com/hahahakc/p/13299484.html
Copyright © 2020-2023  润新知