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>

效果图:

相关推荐
老前端的功夫5 小时前
Vue 3 性能深度解析:从架构革新到运行时的全面优化
javascript·vue.js·架构
天天扭码5 小时前
如何实现流式输出?一篇文章手把手教你!
前端·aigc·ai编程
前端 贾公子5 小时前
vue移动端适配方案 === postcss-px-to-viewport
前端·javascript·html
GISer_Jing6 小时前
AI营销增长:4大核心能力+前端落地指南
前端·javascript·人工智能
明远湖之鱼7 小时前
一种基于 Service Worker 的渐进式渲染方案的基本原理
前端
前端小端长7 小时前
Vue 中 keep-alive 组件的原理与实践详解
前端·vue.js·spring
FeelTouch Labs7 小时前
Nginx核心架构设计
运维·前端·nginx
雪球工程师团队8 小时前
别再“苦力”写后台,Spec Coding “跑” 起来
前端·ai编程
m0_471199638 小时前
【场景】前端怎么解决离线收银、数据同步异常等场景问题
前端·javascript