breadcrumb.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <el-breadcrumb class="breadcrumb" separator="/">
  3. <el-breadcrumb-item :to="{ path: '/frame' }">首页</el-breadcrumb-item>
  4. <el-breadcrumb-item v-for="(item, index) in list" :key="index">{{ item.title }}</el-breadcrumb-item>
  5. </el-breadcrumb>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. menuItems: Array
  11. },
  12. data () {
  13. return {
  14. routers: []
  15. }
  16. },
  17. computed: {
  18. list () {
  19. const path = this.$route.path
  20. if (path === '/frame') return false
  21. const item = this.items(path)
  22. return item
  23. }
  24. },
  25. methods: {
  26. items (path) {
  27. const menuList = []
  28. const nemus = (path) => {
  29. this.menuItems.filter(p => {
  30. if (`/frame${p.path}` === path) {
  31. if (p.parentId !== null && p.parentId !== '') {
  32. const item = this.menuItems.filter(i => i.id === p.parentId)
  33. nemus(`/frame${item[0].path}`)
  34. }
  35. menuList.push(p)
  36. }
  37. })
  38. }
  39. nemus(path)
  40. return menuList
  41. }
  42. },
  43. mounted () {}
  44. }
  45. </script>
  46. <style lang="less" scoped>
  47. .breadcrumb {
  48. line-height: 2em;
  49. text-indent: 0.5em;
  50. border-bottom: 1px solid #e6e6e6;
  51. }
  52. </style>