index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div class="crumbs">
  3. <ul>
  4. <li v-if="list[0]">
  5. <span class="name" :title="list[0].name" @click="onClickPath(0)">{{list[0].name}}</span>
  6. </li>
  7. <li v-if="list.length > 3">...</li>
  8. <li v-if="list.length > 2">
  9. <span class="name" :title="list[list.length - 2].name" @click="onClickPath(list.length - 2)">{{list[list.length - 2].name}}</span>
  10. </li>
  11. <li v-if="list.length > 1">
  12. <span class="name" :title="list[list.length - 1].name" @click="onClickPath(list.length - 1)">{{list[list.length - 1].name}}</span>
  13. </li>
  14. </ul>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. props:['list'],
  20. methods: {
  21. onClickPath(idx) {
  22. if (idx !== this.list.length - 1) {
  23. this.$emit('click-path', idx)
  24. }
  25. }
  26. }
  27. }
  28. </script>
  29. <style lang="less" scoped>
  30. .crumbs{
  31. >ul{
  32. display: flex;
  33. align-items: center;
  34. >li{
  35. font-size: 18px;
  36. color: #969799;
  37. line-height: 28px;
  38. .name{
  39. max-width: 285px;
  40. overflow: hidden;
  41. white-space: pre;
  42. text-overflow: ellipsis;
  43. cursor: pointer;
  44. }
  45. &::after {
  46. content: '>';
  47. margin-left: 7px;
  48. margin-right: 7px;
  49. }
  50. &:last-of-type{
  51. font-size: 18px;
  52. font-weight: bold;
  53. color: #333333;
  54. line-height: 28px;
  55. .name {
  56. cursor: default;
  57. }
  58. &::after {
  59. content: '';
  60. }
  61. }
  62. }
  63. }
  64. }
  65. </style>