bread.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <el-breadcrumb separator="/">
  3. <el-breadcrumb-item v-if="routerHome" :to="{ path: '/frame/@user/xms/' }">首页</el-breadcrumb-item>
  4. <el-breadcrumb-item v-else>首页</el-breadcrumb-item>
  5. <el-breadcrumb-item v-for="(item, index) in catalog" :key="index">{{ item }}</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. </template>
  8. <script>
  9. const DeepFind = (menus, path) => {
  10. for (const k in menus) {
  11. const item = menus[k];
  12. //if (item.options.path == path) return menus[k];
  13. if (path.endsWith(item.options.path)) return menus[k];
  14. if (item.children) {
  15. const res = DeepFind(item.children, path);
  16. if (res) return res;
  17. }
  18. }
  19. return false;
  20. };
  21. const routerHome = eval(process.env.VUE_APP_ROUTER_HOME);
  22. export default {
  23. computed: {
  24. catalog() {
  25. // console.log(this.$route)
  26. // return this.$route.meta.catalog;
  27. const menu = DeepFind(this.menuItems, this.$route.path);
  28. return (menu && menu.options && menu.options.meta && menu.options.meta.catalog) || [];
  29. },
  30. menuItems() {
  31. return this.$store.getters.menuItems;
  32. },
  33. },
  34. data() {
  35. return {
  36. routerHome,
  37. };
  38. },
  39. };
  40. </script>