zhiyong.zhou
2024-02-26 60d911172b1dbebe0ab952ce10366b327d5744f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<template>
  <div class="route-tab">
    <el-tabs v-bind="$attrs" :value="$route.path" @tab-click="handleClick">
      <el-tab-pane
        v-for="route in routes"
        :key="route.path"
        :label="route.label"
        :name="route.path"
        :disabled="route.disabled"
        :closable="route.closable"
      >
        <slot v-if="route.path === $route.path"></slot>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
 
<script>
export default {
  name: 'RouteTab',
  props: {
    routes: {
      type: Array,
      default: () => []
    },
  },
  methods: {
    handleClick(tab) {
      this.$router.push({
        path: tab.name,
      })
    },
  },
}
</script>