欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2019年07月01日 10:23:29   作者:zyx  
這篇文章主要介紹了vue的面包屑導航組件,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下

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 中的面包屑設(shè)置的,

<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>

總結(jié)

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

相關(guān)文章

  • vue-cli 為項目設(shè)置別名的方法

    vue-cli 為項目設(shè)置別名的方法

    這篇文章主要介紹了vue-cli 為項目設(shè)置別名的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-10-10
  • Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題

    Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題

    這篇文章主要介紹了Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • Vue 動態(tài)組件與 v-once 指令的實現(xiàn)

    Vue 動態(tài)組件與 v-once 指令的實現(xiàn)

    這篇文章主要介紹了Vue 動態(tài)組件與 v-once 指令的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-02-02
  • vue中自定義指令directive的詳細指南

    vue中自定義指令directive的詳細指南

    這篇文章主要給大家介紹了關(guān)于vue中自定義指令directive的相關(guān)資料,自定義指令解決的問題或者說使用場景是對普通 DOM 元素進行底層操作,所以我們不能盲目的胡亂的使用自定義指令,需要的朋友可以參考下
    2021-09-09
  • vue cli實現(xiàn)項目登陸頁面流程詳解

    vue cli實現(xiàn)項目登陸頁面流程詳解

    CLI是一個全局安裝的npm包,提供了終端里的vue命令。它可以通過vue create快速搭建一個新項目,或者直接通過vue serve構(gòu)建新想法的原型。你也可以通過vue ui通過一套圖形化界面管理你的所有項目
    2022-10-10
  • 詳解使用vue-admin-template的優(yōu)化歷程

    詳解使用vue-admin-template的優(yōu)化歷程

    這篇文章主要介紹了詳解使用vue-admin-template的優(yōu)化歷程,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • ElementUI表單驗證validate和validateField的使用及區(qū)別

    ElementUI表單驗證validate和validateField的使用及區(qū)別

    Element-UI作為前端框架,最常使用到的就是表單驗證,下面這篇文章主要給大家介紹了關(guān)于ElementUI表單驗證validate和validateField的使用及區(qū)別,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-02-02
  • Vue3中props和emit的使用方法詳解

    Vue3中props和emit的使用方法詳解

    props是Vue中最常見的父子通信方式,使用起來也比較簡單,下面這篇文章主要給大家介紹了關(guān)于Vue3中props和emit的使用方法,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-03-03
  • Vue express鑒權(quán)零基礎(chǔ)入門

    Vue express鑒權(quán)零基礎(chǔ)入門

    這篇文章主要介紹了詳解express鑒權(quán),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-02-02
  • element?select必填項驗證回顯問題的解決

    element?select必填項驗證回顯問題的解決

    本文主要介紹了element?select必填項驗證回顯問題的解決,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-04-04

最新評論