微信小程序如何獲取屏幕高度和寬度

方法一
onLoad: function () {
   this.setData({
     height: wx.getSystemInfoSync().windowHeight,
     width: wx.getSystemInfoSync().windowWidth
   })
 }

方法二
.index{
   height: 100vh;
   width: 100vw;
}
# CSS3引入的"vw"和"vh"基於寬度/高度相對於窗口大小 
# "vw" = "view width"  "vh" = "view height"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章