在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ github上的這種功能如何使用vue實(shí)現(xiàn)呢

github上的這種功能如何使用vue實(shí)現(xiàn)呢

圖片描述

github倉庫的項(xiàng)目管理是這種效果。
下圖,查看元素可以看到里面就是個(gè)連接,是個(gè)根據(jù)路由切換組件的功能,上方的藍(lán)色文本隨著進(jìn)入的文件越深層越多。這個(gè)功能貌似被稱作面包屑功能
圖片描述

那么如何使用vue-router實(shí)行這種效果呢?
圖片描述

回答
編輯回答
短嘆

之前自己實(shí)現(xiàn)過一個(gè),但是樣式上有點(diǎn)丑
現(xiàn)在用的是element ui

大致也就是對(duì)一個(gè)對(duì)象循環(huán)一下,綁定下他的name和href,最后一個(gè)樣式和其他不一樣...

2018年9月6日 15:22
編輯回答
我以為

這是一個(gè)二級(jí)的, 多級(jí)的也是這樣實(shí)現(xiàn)的, 在每個(gè)router上加上meta屬性

<template>
  <div class="breadcrumb">
    <span class="parent">{{parent}}</span>
    <span class="separator">&#62;</span>
    <span class="current">{{current}}</span>
  </div>
</template>
<script type="text/javascript">
  export default {
    name: 'breadcrumb',
    data() {
      return {
        parent: '',
        current: ''
      }
    },
    created() {
      console.log('...',this.$route)
      this.setPath(this.$route);
    },
    methods: {
      setPath(route) {
        this.parent = route.matched[0].meta;
        this.current = route.meta;
      }
    },
    watch: {
      '$route': 'setPath'
    }
  }
</script>
2017年4月11日 02:27
編輯回答
誮惜顏
正好寫過相關(guān)功能,由于要求顯示中文,所以在route定義的時(shí)候 ,meta里加入了一個(gè)title屬性,
其實(shí)最主要就是第一句,這里有你想要的一切
getBreacrumb () {
      // console.log(this.$route.matched)
      let matched = this.$route.matched.filter(item => item.meta.title)
      // console.log(matched)
      const first = matched[0]
      if (first && (first.name !== '首頁' || first.path !== '')) {
        matched = [{ name: '首頁', path: '/', meta: {title: '首頁'} }].concat(matched)
      }
      this.items = matched
      this.title = this.$route.meta.title
      // console.log(this.items)
    }
    
    

圖片描述

2018年3月14日 07:27