<template>
  <div class="mt-tab">
    <el-tabs  class="mt-tab-router" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane 
        :label="item.name"
        v-for = "(item, index) in list"
        v-bind:key ="index"
        :name="item.url"></el-tab-pane>
    </el-tabs>
    <router-view></router-view>
  </div>
</template>
<script>
export default {
  data () {
    return {
      activeName: this.$route.path
    }
  },
  watch: {
    '$route' () {
      this.activeName = this.$route.path
    }
  },
  props: {
    list: Array
  },
  methods: {
    handleClick () {
      this.$router.replace(this.activeName)
    }
  }
}
</script>
<style lang="less">
.mt-tab {
  .el-tabs__nav-scroll {
    background: #edf2f6;
  }
  .el-tabs__nav-wrap::after {
    height: 0px;
  }
  .el-tabs--top .el-tabs__item.is-top:last-child {
    padding-right: 20px;
  }
  .el-tabs--top .el-tabs__item.is-top:nth-child(2) {
    padding-left: 20px;
  }
  .el-tabs__nav-prev,
  .el-tabs__nav-next {
    line-height: 50px;
    color: #fff;
    background: darken(#edf2f6, 10%);
  }
  .el-tabs__active-bar {
    height: 50px;
    z-index: 0;
  }
  .el-tabs__item {
    padding: 5px 40px;
    height: 50px;
    color: #8391a5;
    &.is-active {
      color: #fff;
    }
  }
}
</style>
