Nenhuma Descrição

index.vue 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <el-breadcrumb class="app-breadcrumb" separator="/">
  3. <transition-group name="breadcrumb">
  4. <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path" v-if="item.meta.title">
  5. <span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{item.meta.title}}</span>
  6. <router-link v-else :to="item.redirect||item.path">{{item.meta.title}}</router-link>
  7. </el-breadcrumb-item>
  8. </transition-group>
  9. </el-breadcrumb>
  10. </template>
  11. <script>
  12. export default {
  13. created() {
  14. this.getBreadcrumb()
  15. },
  16. data() {
  17. return {
  18. levelList: null
  19. }
  20. },
  21. watch: {
  22. $route() {
  23. this.getBreadcrumb()
  24. }
  25. },
  26. methods: {
  27. getBreadcrumb() {
  28. let matched = this.$route.matched.filter(item => item.name)
  29. const first = matched[0]
  30. if (first && first.name !== 'dashboard') {
  31. matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched)
  32. }
  33. this.levelList = matched
  34. }
  35. }
  36. }
  37. </script>
  38. <style rel="stylesheet/scss" lang="scss" scoped>
  39. .app-breadcrumb.el-breadcrumb {
  40. display: inline-block;
  41. font-size: 14px;
  42. line-height: 50px;
  43. margin-left: 10px;
  44. .no-redirect {
  45. color: #97a8be;
  46. cursor: text;
  47. }
  48. }
  49. </style>