uniapp自定义底部导航

我这边使用的是uview组件库,进行开发的!

html 复制代码
<template>
  <view class="footer-bar">
    <u-tabbar :value="select ? select : 0" @change="changeTab" :border="true" :fixed="true" :placeholder="true"
      activeColor="#d81e06" :safeAreaInsetBottom="false">
      <u-tabbar-item :text="item.title" v-for="(item, index) in footerBarList" :key="index">
        <image class="u-page__item__slot-icon" slot="active-icon" :src="item.select_img"></image>
        <image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.img"></image>
      </u-tabbar-item>
    </u-tabbar>
  </view>
</template>

<script>
export default {
  name: "FooterBar",
  data() {
    return {
      select: 0,
      footerBarList: [
        {
          img: "/static/home.png",
          select_img: "/static/home_select.png",
          pagePath: "pages/home/home",
          title: "首页",
        },
        {
          img: "/static/dai_ban.png",
          select_img: "/static/dai_ban_select.png",
          pagePath: "pages/treatTackle/treatTackle",
          title: "待办",
        },
        {
          img: "/static/mine.png",
          select_img: "/static/mine_select.png",
          pagePath: "pages/mine/mine",
          title: "我的",
        },
      ],
    };
  },
  methods: {
    changeTab(index, name) {
      console.log(index);
      uni.switchTab({
        url: "/" + this.footerBarList[index].pagePath,
      });
    },
  },
};
</script>

<style lang="scss"></style>

效果图:

相关推荐
mCell9 小时前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip9 小时前
Node.js 子进程:child_process
前端·javascript
excel12 小时前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel13 小时前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼15 小时前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping15 小时前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
石金龙16 小时前
[译] Composition in CSS
前端·css
白水清风16 小时前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化
Ticnix16 小时前
函数封装实现Echarts多表渲染/叠加渲染
前端·echarts
用户221520442780016 小时前
new、原型和原型链浅析
前端·javascript