其他分享
首页 > 其他分享> > vue tabs标签页的使用

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>

标签:activeName,vue,tabs,标签,CardApplication,tab,query,mapGetters,type
来源: https://www.cnblogs.com/zhongfang/p/12880254.html