微信小程序 自适应高度 操作

通过css设置以便子元素使用height:100%
page {
width: 100% ;
height: 100% ;
}

通过js设置

var that = this ;
// 高度自适应
wx .getSystemInfo ({
success : function (res ) {
var clientHeight = res .windowHeight - 120 ,
clientWidth = res .windowWidth ,
rpxR = 750 / clientWidth ;
var calc = clientHeight * rpxR ;
//console.log(calc)
that .setData ({
winHeight : calc
});
}
});
< swiper duration= "1000" class= 'swipertsp' current= "1" circular= "true"
        bindchange= "change"
        bindanimationfinish= "intervalChange"
        style= "height:{{winHeight}}rpx" >
< block >
< swiper-item wx:for= "{{swiper}}" wx:key= "{{index}}" >
< scroll-view scroll-y= "true" style= "height:{{winHeight}}rpx" >
< div >
</ div >
</ scroll-view >
</ swiper-item >
</ block >
</ swiper >



猜你喜欢

转载自blog.csdn.net/qinlulucsdn/article/details/80692695