给swiper手动设置高度属性{{height}}  

头部三个导航栏

<view class="swiper-tab">

<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">发表</view>

<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">浏览</view>

<view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab">收藏</view>

</view>

下边对应的tab

<swiper class="seiper daodi" current="{{currentTab}}" duration="300" bindchange="swiperTab" style="height:{{height}}px;">

<swiper-item class="tab1">发表</swiper-item>

<swiper-item class="tab2">浏览</swiper-item>

<swiper-item class="tab1">收藏</swiper-item>

</swiper>

js文件写一个动态设置height属性的方法

// 动态设置高度 (page当前页数从1开始,length 下拉后请求到的数据个数,每个table高度设置200px 250px为多余设置为底部留下间隙) 

每次请求完数据后访问shezhiHeight 函数可以动态的修改高度 完美解决

shezhiHeight:function(page , length){

var H = ((page - 1) * 10 + length ) * 200 + 250

this.setData({

height:H

})

}

 

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐