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>

效果图:

相关推荐
Kagol1 小时前
TinyVue 支持 Skills 啦!现在你可以让 AI 使用 TinyVue 组件搭建项目
前端·agent·ai编程
柳杉1 小时前
从零打造 AI 全球趋势监测大屏
前端·javascript·aigc
simple_lau1 小时前
Cursor配置MasterGo MCP:一键读取设计稿生成高还原度前端代码
前端·javascript·vue.js
睡不着先生1 小时前
如何设计一个真正可扩展的表单生成器?
前端·javascript·vue.js
天蓝色的鱼鱼1 小时前
模块化与组件化:90%的前端开发者都没搞懂的本质区别
前端·架构·代码规范
明君879971 小时前
Flutter 如何给图片添加多行文字水印
前端·flutter
进击的尘埃1 小时前
AI 代码审查工具链搭建:用 AST 解析 + LLM 实现自动化 Code Review 的前端工程方案
javascript
juejin_cn1 小时前
[转][译] 从零开始构建 OpenClaw — 第五部分(对话压缩)
javascript
leolee182 小时前
Redux Toolkit 实战使用指南
前端·react.js·redux
bluceli2 小时前
React Hooks最佳实践:写出优雅高效的组件代码
前端·react.js