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


方法一:

 

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"

 

轉自博客:https://www.jianshu.com/p/cfc7c63e63a7


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM