首页 > 其他 > 详细

小程序的一个tab切换

时间:2017-02-06 12:07:52      阅读:385      评论:0      收藏:0      [点我收藏+]
<view class="tab-left" bindtap="tab">  
  <view class="{{tabArr.curHdIndex==‘0‘? ‘active‘ : ‘‘}}" id="tab-hd01" data-id="0">tab-hd01</view>  
  <view class="{{tabArr.curHdIndex==‘1‘? ‘active‘ : ‘‘}}" id="tab-hd02" data-id="1">tab-hd01</view>  
  <view class="{{tabArr.curHdIndex==‘2‘? ‘active‘ : ‘‘}}" id="tab-hd03" data-id="2">tab-hd01</view>  
  <view class="{{tabArr.curHdIndex==‘3‘? ‘active‘ : ‘‘}}" id="tab-hd04" data-id="3">tab-hd01</view>  
</view>  

<view class="tab-right">  
  <view class="right-item {{tabArr.curBdIndex==‘0‘? ‘active‘ : ‘‘}}">tab-bd01</view>  
  <view class="right-item {{tabArr.curBdIndex==‘1‘? ‘active‘ : ‘‘}}">tab-bd02</view>  
  <view class="right-item {{tabArr.curBdIndex==‘2‘? ‘active‘ : ‘‘}}">tab-bd03</view>  
  <view class="right-item {{tabArr.curBdIndex==‘3‘? ‘active‘ : ‘‘}}">tab-bd04</view>  
</view>  
</view>

 js代码

Page( {  
data: {  
  tabArr: {  
    curHdIndex: 0,  
    curBdIndex: 0  
  },  
},
 /**
     * tab切换
     */
    tab: function(e) {
        var dataId = e.currentTarget.id;
        var obj = {};
        obj.curHdIndex = dataId;
        obj.curBdIndex = dataId;
        this.setData({
            tabArr: obj
        })
    },

 

小程序的一个tab切换

原文:http://www.cnblogs.com/lwwen/p/6369376.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!