<template>
  <div id="station">
    <ul>
      <li v-for="(tab,index) in tabs" @click="toggle(index,tab.view)" :class="{active:active==index}">
        {{tab.type}}
      </li>
    </ul>
    <!--:is实现多个组件实现同一个挂载点-->
    <component :is="currentView"></component>
  </div>
</template>

<script>
  import info from '../info/index.vue'
  import pay from '../pay/index.vue'
  import notice from '../notice/index.vue'
  export default {
    name: 'Common',
    data(){
      return {
        active:0,
        currentView:'油站信息',
        tabs:[
          {
            type:'油站信息',
            view:'info'
          },
          {
            type:'支付配置',
            view:'pay'
          },
          {
            type:'设备管理',
            view:'notice'
          }
        ]
      }
    },
    methods:{
      toggle(i,v){
        this.active=i;
        this.currentView=v;
      }
    },
    components:{
      info,
      pay,
      notice
    }
  }
</script>

<style>
  #station {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* text-align: center;
    color: #2c3e50;
    margin-top: 60px; */
  }
  ul{
    width:500px;
    display:flex;
  }
  ul li{
    width:100px;
    height:40px;
    /*background: #ccc;*/
    display: inline-flex;
    border-right:1px solid #ddd;
    justify-content: center;
    align-items: center;
    cursor:pointer
  }
  ul li.active{
    /*background:#333;*/
  }
</style>
