breadcrumb.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="listRouterBox">
  3. <span class="location">当前位置:</span>
  4. <el-breadcrumb :separator-icon="ArrowRight">
  5. <el-breadcrumb-item>
  6. <NuxtLink to="/">首页</NuxtLink>
  7. </el-breadcrumb-item>
  8. <!--只要出现第二级一定是跳转到频道页-->
  9. <el-breadcrumb-item v-if="parent_name != ''">
  10. <NuxtLink :to="`/${parent_pinyin}/index.html`">{{parent_name}}</NuxtLink>
  11. </el-breadcrumb-item>
  12. <el-breadcrumb-item>
  13. <span class="routeName" v-if="parent_name==''||routeType=='list'||routeType=='list'">
  14. {{ name }}
  15. </span>
  16. <!-- <NuxtLink :to="`/${parent_pinyin}/${pinyin}/list-1.html`" class="routeName" v-else>
  17. {{ name }}
  18. </NuxtLink> -->
  19. </el-breadcrumb-item>
  20. <!--详情页增加文章标题作为结束-->
  21. </el-breadcrumb>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { ref } from 'vue';
  26. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus';
  27. import { ArrowRight } from '@element-plus/icons-vue';
  28. //获得页面的routeId导航池id
  29. const props = defineProps({
  30. routeId: Number,
  31. });
  32. //1.获得当前路由的层级
  33. const route = useRoute();
  34. const routeType = ref('');
  35. //判断当前处于哪个层级
  36. //第二层的列表
  37. if(route.name=='dir-dir-list-id'){
  38. routeType.value = 'list'
  39. }
  40. //第一层的列表
  41. if(route.name=='dir-list-id'){
  42. routeType.value = 'list'
  43. }
  44. //2.获得当前栏目的名称 面包屑的最后一级
  45. const name = ref('')
  46. const pinyin = ref('');
  47. //3.获得父级栏目 面包屑倒数第二级
  48. const parent_name = ref("");
  49. const parent_id = ref("");
  50. const parent_pinyin = ref("");
  51. const parent_children_count = ref(0);
  52. const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
  53. method: 'GET',
  54. query: {
  55. 'catid': props.routeId
  56. },
  57. });
  58. if (pageName.code == 200) {
  59. //最后一级
  60. name.value = pageName.data.alias
  61. pinyin.value = pageName.data.aLIas_pinyin;
  62. //倒数第二级 如果存在
  63. parent_name.value = pageName.data.parent_name;
  64. parent_id.value = pageName.data.parent_id;
  65. parent_pinyin.value = pageName.data.parent_pinyin;
  66. parent_children_count.value = pageName.data.children_count;
  67. console.log(pageName)
  68. }
  69. </script>
  70. <style lang="less" scoped>
  71. //导航条
  72. .listRouterBox {
  73. width: 100%;
  74. height: 52px;
  75. font-family: Microsoft YaHei, Microsoft YaHei;
  76. font-weight: 400;
  77. font-size: 16px;
  78. color: #999;
  79. text-align: left;
  80. font-style: normal;
  81. text-transform: none;
  82. .routeName {
  83. color: #333;
  84. }
  85. :deep(.el-breadcrumb) {
  86. display: inline-block;
  87. vertical-align: -4px;
  88. }
  89. :deep(.el-breadcrumb__inner a),
  90. :deep(.el-breadcrumb__inner.is-link) {
  91. color: #999;
  92. font-weight: 400;
  93. text-decoration: none;
  94. transition: var(--el-transition-color);
  95. }
  96. span {
  97. font-family: Microsoft YaHei, Microsoft YaHei;
  98. font-weight: 400;
  99. font-size: 20px;
  100. color: #999;
  101. line-height: 23px;
  102. text-align: left;
  103. font-style: normal;
  104. text-transform: none;
  105. }
  106. .location {
  107. margin-right: 20px;
  108. width: 100px;
  109. height: 22px;
  110. font-family: Microsoft YaHei, Microsoft YaHei;
  111. font-weight: 400;
  112. font-size: 20px;
  113. color: #999;
  114. line-height: 23px;
  115. text-align: left;
  116. font-style: normal;
  117. text-transform: none;
  118. }
  119. }
  120. </style>