Slot.vue 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <main class="app-main">
  3. <router-tab>
  4. <template v-slot="{ tab: { id, title, icon, closable }, tabs, index}">
  5. <i
  6. v-if="icon"
  7. class="tab-icon"
  8. :class="icon"
  9. />
  10. <span class="tab-title">{{ title || '未命名页签' }}</span>
  11. <span class="tab-badge">{{ index }}</span>
  12. <i
  13. v-if="closable !== false &&tabs.length > 1"
  14. class="tab-close el-icon-close"
  15. @click.prevent="$routerTab.close(id)"
  16. />
  17. </template>
  18. </router-tab>
  19. </main>
  20. </template>
  21. <style lang="scss" scoped>
  22. .tab-badge {
  23. $s: 1.2em;
  24. display: inline-block;
  25. margin-left: 3px;
  26. width: $s;
  27. height: $s;
  28. font-size: 12px;
  29. line-height: $s;
  30. vertical-align: super;
  31. text-align: center;
  32. color: #fff;
  33. background-color: #f80;
  34. border-radius: 100%;
  35. }
  36. .router-tab-item.actived .tab-badge {
  37. background-color: #f50;
  38. }
  39. </style>