微信小程序scroll-view(或者其他view) 计算高度 px转rpx有关


 wx.getSystemInfo({
      success: function (res) {
        that.globalData.winWidth = res.windowWidth;
        that.globalData.winHeight = res.windowHeight;
      }
    })

 

以上,app.js中 先获取整体高度 赋值给全局变量

<swiper class='swiper' current="{{currentTab}}" duration="300" bindchange="bindChange" style="height:{{winHeight}}px">

以上.wxml代码 style height 赋值 使用方法

 

//定义高度
Page({
  data: {
    winHeight: 0
 },
})

onLoad: function (options) {
 this.setData({
      winHeight: app.globalData.winHeight -                    
                            wx.getSystemInfoSync().screenWidth / 750 * (155)
    })
}

以上 js 是其他控件预留 155rpx情况下

swiper 控件的高度

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM