<template>
  <div class="tab-bar">
    <van-tabbar v-model="currentIndex">
      <template v-for="(item, index) in tabbarData" :key="index">
        <van-tabbar-item :to="item.path">
          <span>自定义</span>
          <template #icon="props">
            <img
              :src="getAssetUrl(item.activeImg)"
              alt=""
              v-if="currentIndex === index"
            />
            <img :src="getAssetUrl(item.image)" alt="" v-else />
          </template>
        </van-tabbar-item>
      </template> </van-tabbar
    >y
  </div>
</template>

<script setup>
import tabbarData from '@/assets/data/tabbar.js'
import { getAssetUrl } from '@/utils/getAssetUrl.js'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const currentIndex = ref(0)
const itemClick = (index, routePath) => {
  router.push(routePath)
}
</script>

<style scoped lang="less">
.tab-bar {
  --van-tabbar-item-icon-size: 35px !important;
  height: 50px;
  position: fixed;
  left: 0;
  bottom: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  border-top: 1px solid #f3f3f3;
  :deep(.van-tabbar-item__icon) {
    font-size: 50px;
  }
  .activeClass {
    color: red;
  }
  img {
    height: 24px;
  }
}
</style>
