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>

效果图:

相关推荐
阿伟实验室21 小时前
debian10部署简易web服务器
运维·服务器·前端
云枫晖21 小时前
Vue3 响应式原理:从零实现 Reactive
前端·vue.js
月弦笙音21 小时前
【AI】👉提示词入门基础篇指南
前端·后端·aigc
konh21 小时前
React Native 自定义字体导致 Text / TextInput 文本垂直不居中的终极解决方案
前端·react native
奔赴_向往21 小时前
跨域问题深度剖析:为何CORS设置了还是报错?
前端
纯爱掌门人21 小时前
别再死磕框架了!你的技术路线图该更新了
前端·架构·前端框架
没头脑的男大21 小时前
Unet实现脑肿瘤分割检测
开发语言·javascript·ecmascript
丁点阳光21 小时前
Ract Router v7:最全基础与高级用法指南(可直接上手)
前端·react.js
~无忧花开~1 天前
Vue.config.js配置全攻略
开发语言·前端·javascript·vue.js
w***Q3501 天前
前端跨平台开发工具,Tauri与Electron
前端·javascript·electron