vue tabs标签页的使用

<template>
  <div class="apply">
      <div class="tabs">
        <el-tabs v-model="activeName" @tab-click="handleClick" lazy='true'>
          <el-tab-pane label="补卡申请" name="CardApplication"></el-tab-pane>
          <el-tab-pane label="请假申请" name="LeaveApplication"></el-tab-pane>
          <el-tab-pane label="出差申请" name="BusinessTravel"></el-tab-pane>
          <el-tab-pane label="外出申请" name="OutApplication"></el-tab-pane>
          <el-tab-pane label="打车申请" name="TaxiApplication"></el-tab-pane>
          <el-tab-pane label="加班申请" name="OvertimeApplication"></el-tab-pane>
        </el-tabs>
     </div>
      <!-- 详细页面 -->
      <div class="content" >
        <router-view />
      </div>
    </div>
</template>
<script>
import {
  mapGetters
} from 'vuex'
export default {
  data() {
    return {
        activeName: ''
    }
  },
  computed: {
    ...mapGetters([
      'username'
    ])
  },
  created() {
    if(!this.$route.query.type){
      this.$router.push('/Personal/Apply/CardApplication')
      this.activeName = 'CardApplication'
    }
          // 判断是不是第一次进入这个页面,如果第一次进入则去CardApplication
  	this.activeName = this.$route.query.type || 'CardApplication'
  },
  mounted() {
    // console.log(this.username)
  },
  methods:{
    // Tabs选中时触发
    handleClick(tab, event) {
      this.$router.push({
        path: `/Personal/Apply/${tab.name}`,
        query: {
          type: tab.name
        }
      });
    }
  }
}
</script>

posted @ 2020-05-13 08:55  zhongfang99  阅读(3682)  评论(1编辑  收藏  举报