国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue中的面包屑導航組件實例代碼

2024-05-06 15:37:16
字體:
來源:轉載
供稿:網友

vue的面包屑導航組件

用來將其放到navbar中;

Breadcrumb/index.vue

<template>  <el-breadcrumb class="app-breadcrumb" separator="/">   <transition-group>    <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path" v-if="item.meta.title">     <span  v-if='item.redirect==="noredirect"||index==levelList.length-1' class="no-redirect">{{item.meta.title}}</span>     <router-link  v-else :to="item.redirect||item.path">{{item.meta.title}}</router-link>    </el-breadcrumb-item>   </transition-group>  </el-breadcrumb></template><script>  export default {    name: "idnex",   data(){     return {      levelList:null     }   },   created() {    this.getBreadcrumb()   },   watch:{    $route(){     this.getBreadcrumb()    }   },   methods:{    getBreadcrumb(){      let matched=this.$route.matched.filter(item=>item.name)//$route.matched 將會是一個包含從上到下的所有對象 (副本)。      const first=matched[0]      if(first && first.name !=='dashboard'){//$route.name當前路由名稱 ;$route.redirectedFrom重定向來源的路由的名字       matched=[{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)      }      this.levelList=matched     }   }  }</script><style rel="stylesheet/scss" lang="scss" scoped> .app-breadcrumb.el-breadcrumb {  display: inline-block;  font-size: 14px;  line-height: 50px;  margin-left: 10px;  .no-redirect {   color: #97a8be;   cursor: text;  } }</style>

ps:下面在看下一段代碼Vue 面包屑導航

樣式采用的是element ui 中的面包屑設置的,

<template><el-breadcrumb><el-breadcrumb-item separator = '/' v-for = "(item,index) in breadlist" :key = 'index' :to="{path: item.path}">{{item.meta.CName}}</el-breadcrumb-item> </el-breadcrumb></template>js部分<script>export default {data(){return {breadlist: ''}},created() {this.getBread();},methods:{getBread(){this.breadlist = this.$route.matched;this.$route.matched.forEach((item,index)=>{//先判斷父級路由是否是空字符串或者meta是否為首頁,直接復寫路徑到根路徑item.meta.CName === '首頁' ? item.path = '/' : this.$route.path === item.path;});}},watch:{$route(){this.getBread();}}}</script>

總結

以上所述是小編給大家介紹的vue中的面包屑導航組件實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對錯新站長站網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 南开区| 朝阳市| 原平市| 宁波市| 治多县| 巨野县| 玉田县| 昆山市| 安岳县| 泊头市| 河间市| 靖宇县| 广州市| 太保市| 克山县| 朝阳市| 鱼台县| 德阳市| 开封市| 策勒县| 宣恩县| 万安县| 花莲市| 石楼县| 宾阳县| 大港区| 明光市| 慈利县| 延川县| 类乌齐县| 盘锦市| 瑞昌市| 太湖县| 长白| 珠海市| 宿迁市| 大邑县| 井陉县| 邹平县| 凭祥市| 阳山县|