快应用底部导航栏

在这里插入图片描述
在这里插入图片描述
代码如下:

<template>
  <div class="wrapper">
    <!-- tab导航 -->
    <div class="fix-bar">
      <!-- 首页 -->
      <div class="bar index" @click="tabClick('Index')">
        <image
          class="img"
          src="/assets/img/shouye{{numIndex}}.png"
          style="object-fit: contain"
        ></image>
        <text class="text-index">首页</text>
      </div>
      <!-- 咨讯 -->
      <div class="bar setting" @click="tabClick('News')">
        <image
          class="img"
          src="/assets/img/news{{numNews}}.png"
          style="object-fit: contain"
        ></image>
        <text class="text-index">资讯</text>
      </div>
      <!-- 我的 -->
      <div class="bar setting" @click="tabClick('Mine')">
        <image
          class="img"
          src="/assets/img/wode{{numMine}}.png"
          style="object-fit: contain"
        ></image>
        <text class="text-index">我的</text>
      </div>

    </div>
  </div>
</template>

<script>
import router from '@system.router'

export default {
  data: {
    numIndex: 1,
    numNews: 0,
    numMine: 0,
  },
  onInit() {
    let pageName = this.$page.currentPageName || this.$page.name
    if (pageName === "pages/Index") {
      this.numIndex = 1
      this.numMine = 0
      this.numNews = 0
    } else if (pageName === "pages/News") {
      this.numIndex = 0
      this.numMine = 0
      this.numNews = 1
    } else if (pageName === "pages/Mine" || pageName === "pages/Setting" || pageName === "pages/Login") {
      this.numIndex = 0
      this.numMine = 1
      this.numNews = 0
    }
  },
  tabClick(type) {
    router.replace({
      uri: "pages/" + type
    })
  }
}
</script>

<style lang="less">

.wrapper {
  width: 100%;
  display: flex;
  flex-flow: row wrap;
  flex-direction: column; /*纵向排列 */
  background: linear-gradient(
    to right,
    rgb(156, 203, 241) 500px,
    rgb(254, 255, 255) 99%
  );
  .fix-bar {
    height: 100px;
    position: fixed;
    bottom: 0px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-top: 1px solid #ccc;
    .bar {
      width: 33%;
      justify-content: center;
      flex-direction: column;
      align-items: center;
    }
    .img {
      width: 32px;
      height: 32px;
    }
    .text-index {
      color: rgba(54, 54, 54, 1);
      font-size: 20px;
    }
  }
}
</style>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

礼礼。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值