zoukankan      html  css  js  c++  java
  • 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"),
          },
        ],
      }

  • 相关阅读:
    php高效率写法
    php经典bug
    cideogniter部署到阿里云服务器出现session加载错误
    linux gcc编译protocol
    linux权限问题
    http协议详解
    哈希表
    c语言函数
    socket相关函数
    构建之法阅读笔记05
  • 原文地址:https://www.cnblogs.com/hahahakc/p/13299484.html
Copyright © 2011-2022 走看看