PageTabView.vue 1.25 KB
<template>
  <div class="page-tab-view">
    <el-tabs :value="activeKey" @tab-click="changeRouter">
      <el-tab-pane v-for="v in secondaryRoutes" :key="v.path" :name="v.path">
        <template slot="label">
          <i v-if="v.meta.icon" :class="['tab-icon', v.meta.icon]"></i>
          <span class="tab-label">{{ v.meta.title }}</span>
        </template>
      </el-tab-pane>
    </el-tabs>
    <div class="out-box">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    activeKey() {
      return this.$route.path;
    },
    ...mapGetters(["secondaryRoutes"]),
  },
  created() {},
  methods: {
    changeRouter(e) {
      this.$router.push(e.name);
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.el-tabs__nav-scroll) {
  padding-left: 15px;
  .tab-icon {
    margin-right: 5px;
    color: #2681e8;
  }
  .tab-label {
    font-weight: bold;
    color: rgba(0, 0, 0, 0.65);
  }
  .is-active {
    .tab-label {
      color: #2681e8;
    }
  }
}
.page-tab-view {
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  .out-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
  }
}
</style>