footer.vue 1.39 KB
<template>
  <el-row class="footer-wrap">
    <template v-for="item in footBtn">
      <el-col :span="8" class="footer-btn" @click="linkTo(item.path)">
        <el-image class="btn-img" fit="contain"
                  :src="item.isActive ? getImage(item.icon1, '/home'): getImage(item.icon2, '/home')"/>
        <div :class="item.isActive ? 'btn-dsc active' : 'btn-dsc'">{{ item.name }}</div>
      </el-col>
    </template>

    <div v-show="false">{{ route.path }}</div>
  </el-row>
</template>

<script setup lang="ts">
const route = useRoute();
import router from "../router/index";
import getImage from './../assets/getImage'

let footBtn = reactive([
  {
    name: '首页',
    path: '/',
    isActive: false,
    icon1: 'home1.png',
    icon2: 'home2.png',
  },
  {
    name: '采购融资',
    path: '/product',
    isActive: false,
    icon1: 'product1.png',
    icon2: 'product2.png',
  },
  {
    name: '我的',
    path: '/mine',
    isActive: false,
    icon1: 'mine1.png',
    icon2: 'mine2.png',
  }
])

watchEffect(() => {
  footBtn.forEach(item => {
    item.isActive = false
    if (item.path == route.path) {
      item.isActive = true
    }
  })
})

let linkTo = (url: string) => {
  router.push(url)
}
</script>

<style scoped>
.btn-dsc.active {
  background: linear-gradient(0deg, #475EE2 0%, #717AFD 81.0791015625%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
</style>