iotBreadcrumb.vue 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div class="home-breadcrumb">
  3. <a-breadcrumb>
  4. <a-breadcrumb-item @click="toHome">首页</a-breadcrumb-item>
  5. <a-breadcrumb-item v-for="item in levelList" :key="item.name">{{ item.meta.breadcrumb }}</a-breadcrumb-item>
  6. </a-breadcrumb>
  7. <br>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. levelList: []
  15. }
  16. },
  17. watch: {
  18. $route(route) {
  19. this.getBreadcrumb()
  20. }
  21. },
  22. created() {
  23. this.getBreadcrumb()
  24. },
  25. methods: {
  26. getBreadcrumb() {
  27. this.levelList = []
  28. let arr = this.$route.matched
  29. for (let i = 1; i < arr.length; i++) {
  30. this.levelList.push(arr[i])
  31. }
  32. },
  33. toHome() {
  34. this.$router.push('home');
  35. },
  36. handleLink(item) {
  37. let path = item
  38. this.$router.push(path)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="less" scoped>
  44. .home-breadcrumb {
  45. //display: inline-block;
  46. //vertical-align: top;
  47. //font-size: 14px;
  48. height: 25px;
  49. margin: 10px 0px 10px 10px;
  50. }
  51. </style>