TabBar.vue 894 Bytes
<template>
  <van-tabbar
    route
    @change="change"
    v-model="value"
    :border="false"
  >
    <template v-for="(i,index) in data">
      <van-tabbar-item
        :key="index"
        replace
        :to="`/${i.name}`"
        :icon="i.icon"
        :name="i.name"
      >{{i.title}}</van-tabbar-item>
    </template>
  </van-tabbar>
</template>
<script>
export default {
  name: 'TabBar',
  props: {
    data: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      value: ''
    }
  },
  methods: {
    change (value) {
      this.$emit('change', value)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped  lang='scss'>
.van-tabbar {
  box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.1), 0px 0px 0px 0px #e5e5e5;
  .van-tabbar-item--active {
    color: #3975C6;
  }
}
</style>