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>

效果图:

相关推荐
10年前端老司机1 小时前
什么!纯前端也能识别图片中的文案、还支持100多个国家的语言
前端·javascript·vue.js
摸鱼仙人~1 小时前
React 性能优化实战指南:从理论到实践的完整攻略
前端·react.js·性能优化
程序员阿超的博客2 小时前
React动态渲染:如何用map循环渲染一个列表(List)
前端·react.js·前端框架
magic 2452 小时前
模拟 AJAX 提交 form 表单及请求头设置详解
前端·javascript·ajax
程序员小刘6 小时前
HarmonyOS 5中UniApp的调试步骤
华为·uni-app·harmonyos
小小小小宇7 小时前
前端 Service Worker
前端
只喜欢赚钱的棉花没有糖7 小时前
http的缓存问题
前端·javascript·http
饭啦啦8 小时前
uniapp音乐播放createInnerAudioContext
uni-app
小小小小宇8 小时前
请求竞态问题统一封装
前端
loriloy8 小时前
前端资源帖
前端