微信小程序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