美文网首页
微信小程序如何获取屏幕高度和宽度

微信小程序如何获取屏幕高度和宽度

作者: 高阳刘 | 来源:发表于2018-07-11 10:13 被阅读0次

方法一

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.haomeiwen.com/subject/usgcpftx.html