更新:

2019-1-18:自定义tabbar组件已发布

各种奇葩的需求,造就了我们

wxml

 <view class="nav-tabs">
<view class="tab-list {{currentTab == idx?'active':'default'}}" wx:for="{{tabArray}}" wx:key="prototype" wx:for-index="idx" wx:for-item="itemName" data-current="{{idx}}" bindtap="swichNav">{{itemName}}
</view>
</view>
<view class="{{currentTab == idx?'show':'hidden'}} tab-content" wx:for="{{tabArray}}" wx:key="prototype" wx:for-index="idx" wx:for-item="itemName">{{itemName}}-{{idx+1}}
</view>

wxss

 /**index.wxss**/

 page {
display: flex;
flex-direction: column;
height: 100%;
} .nav-tabs {
width: 100%;
height: 75rpx;
display: flex;
position: fixed;
bottom:;
} .tab-content {
flex:;
} .default {
line-height: 75rpx;
text-align: center;
flex:;
border-bottom: 1px solid #eee;
color: #000;
font-weight: bold;
font-size: 28rpx;
} .active {
line-height: 75rpx;
text-align: center;
color: #fc5558;
flex:;
border-bottom: 1px solid red;
font-weight: bold;
font-size: 28rpx;
} .show {
display: block;
flex:;
} .hidden {
display: none;
flex:;
}

js

 //index.js
//获取应用实例
let app = getApp()
Page({
data: {
currentTab: 0,
tabArray: ["tab1", "tab2", "tab3", "tab4"]
},
//事件处理函数
bindChange: function(e) {
let that = this;
that.setData({
currentTab: e.detail.current
});
},
swichNav: function(e) {
let that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
onLoad: function() {
let that = this app.getUserInfo(function(userInfo) { that.setData({
userInfo: userInfo
})
})
}
})

微信小程序 - 自定义tabbar的更多相关文章

  1. 微信小程序自定义 tabbar

    一定的需求情况下,无法使用小程序原生的 tabbar 的时候,需要自行实现一个和 tabbar 功能一模一样的自制组件. 查阅了海量的博客和文档之后,亲自踩坑.总结了三种在不使用微信小程序原生 tab ...

  2. 微信小程序自定义tabbar的实现

    微信小程序自定义tabbar的实现 目的:当采用微信的自定义tabbar组件的时候,切换的时候会出现闪屏的效果:当使用微信默认的tabbar的时候,限制了tabbar的数量以及灵活配置. 方案:自己动 ...

  3. 微信小程序自定义tabbar的问题

    个人感觉小程序的tab样式自定义的能力有所欠缺,不够美观,于是今天自己diy了一个tab 测试的时候发现,无论是使用navigator跳转(会出现点击的效果)还是用bindtap(触摸),因为没有定义 ...

  4. 微信小程序 自定义tabbar实例

    在小程序的开发文档中,对tabbar是这样说明的: 如果小程序是一个多 tab 应用(客户端窗口的底部或顶部有 tab 栏可以切换页面),可以通过 tabBar 配置项指定 tab 栏的表现,以及 t ...

  5. 微信小程序自定义TabBar

    项目中需要根据用户角色控制TabBar中各Item的显示和隐藏,然而小程序自带TabBar没有提供隐藏某个item的功能,只好自己动手写了一个. 1.wxml文件 <view class=&qu ...

  6. 微信小程序 - 自定义tabbar(组件)

    配置项(关于使用组件) index.wxml <!-- tabBar:tabBar配置 activeIndex: 激活页面下标 slots: 多插槽配置(需与页面一致) --> <t ...

  7. 微信小程序——自定义导航栏

    微信头部导航栏可能通过json配置: 但是有时候我们项目需求可能需要自定义头部导航栏,如下图所示: 现在具体说一下实现步骤及方法: 步骤: 1.在 app.json 里面把 "navigat ...

  8. 微信小程序自定义弹窗wcPop插件|仿微信弹窗样式

    微信小程序自定义组件弹窗wcPop|小程序消息提示框|toast自定义模板弹窗 平时在开发小程序的时候,弹窗应用场景还是蛮广泛的,但是微信官方提供的弹窗比较有局限性,不能自定义修改.这个时候首先想到的 ...

  9. 微信小程序-自定义底部导航

    代码地址如下:http://www.demodashi.com/demo/14258.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...

随机推荐

  1. Codeforces Beta Round #11 B. Jumping Jack 数学

    B. Jumping Jack 题目连接: http://www.codeforces.com/contest/11/problem/B Description Jack is working on ...

  2. [Dynamic Language] Python3.7 源码安装 ModuleNotFoundError: No module named '_ctypes' 解决记录

    Python3.7 源码安装 ModuleNotFoundError: No module named '_ctypes' 解决记录 源码安装时报错 File "/home/abeenser ...

  3. Inspect a new tab · cyrus-and/chrome-remote-interface Wiki

    Inspect a new tab · cyrus-and/chrome-remote-interface Wiki Runtime.evaluate

  4. HDU 4497 GCD and LCM (合数分解)

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  5. Android 通话记录分析

    http://stackoverflow.com/questions/6786666/how-do-i-access-call-log-for-android http://android2011de ...

  6. SILICA Xynergy-M4 Board -- STM32F417 meets XILINX Spartan-6

    The SILICA Xynergy-M4 Board combines an ARM Cortex-M4 based STMicroelectronics STM32F417 controller ...

  7. ASP.NET Web Api 实现数据的分页

    前言 这篇文章我们将使用不同的方式实现手动分页(关于高端大气上档次的OData本文暂不涉及,但有可能会在系列的后期介绍,还没确定...),对于分页的结果,我们将采用2种不同的方式响应给客户端(1.将分 ...

  8. Introducing .NET Core

    At connect(), we announced that .NET Core will be entirely released as open source software. I also ...

  9. MultipartFile+nio上传文件

    import java.io.File;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths; ...

  10. 更改mysql字段的编码类型为utf8mb4

    ALTER TABLE tb_case MODIFY COLUMN content VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode ...