微信小程序系列十:自定义底部导航

比较简单代码就不多贴。

template:

<template name="tabbar">
  <view class="weui-tabbar">
    <block wx:for="{{list}}" wx:key="index" wx:for-item="item">
      <navigator url="{{item.url}}" hover-class='none' class="weui-tabbar__item weui-bar__item_on">
        <image src='/image/home.png' class="weui-tabbar__icon"></image>
        <view class="weui-tabbar__label">{{item.name}}</view>
      </navigator>
    </block>
  </view>
</template>

这里样式采用weui的底部导航样式:


.weui-tabbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  position: absolute;
  z-index: 500;
  bottom: 0;
  width: 100%;
  background-color: #f7f7fa;
}

.weui-tabbar:before {
  content: " ";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 1px;
  border-top: 1px solid #c0bfc4;
  color: #c0bfc4;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: scaleY(0.5);
  transform: scaleY(0.5);
}

.weui-tabbar__item {
  display: block;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  padding: 5px 0 0;
  font-size: 0;
  color: #999;
  text-align: center;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.weui-tabbar__item.weui-bar__item_on .weui-tabbar__icon,
.weui-tabbar__item.weui-bar__item_on .weui-tabbar__icon > i,
.weui-tabbar__item.weui-bar__item_on .weui-tabbar__label {
  color: #09bb07;
}

.weui-tabbar__icon {
  display: inline-block;
  width: 27px;
  height: 27px;
}

.weui-tabbar__label {
  text-align: center;
  color: #999;
  font-size: 10px;
  line-height: 1.8;
}

使用方法:在需要使用页面引入模板

<import src="/template/tabbar.wxml" />

<template is="tabbar" data="{{item}}"></template>

代码不全,不懂得可以留言

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值