微信小程序如何获取屏幕的高度和宽度
本文最后更新于:2021年7月29日 下午
微信小程序如何获取屏幕的高度和宽度
- 方法一:
1
2var windowHeight = wx.getSystemInfoSync().windowHeight
var windowWidth = wx.getSystemInfoSync().windowWidth
- 方法二:CSS3中的
1
2
3
4.windowHeightWidthClass {
height: 100vh;
width: 100vw;
}vh
和vw
是相对于屏幕大小的单位,即:vh => view height
vw => view width
如果这篇文章对你有帮助,或者想给我微小的工作一点点资瓷,请随意打赏。

微信支付

支付宝
微信小程序如何获取屏幕的高度和宽度
https://blog.pangao.vip/微信小程序如何获取屏幕的高度和宽度/