wx.getSystemInfo({
success: function(res) {
const screenWidth = res.screenWidth; // 屏幕宽度
const screenHeight = res.screenHeight; // 屏幕高度
wx.createSelectorQuery().selectViewport().boundingClientRect(function(rect) {
const viewportWidth = rect.width; // 视口宽度
const viewportHeight = rect.height; // 视口高度
const fullScreenWidth = screenWidth * viewportWidth / rect.width; // 页面全屏宽度
const fullScreenHeight = screenHeight * viewportHeight / rect.height; // 页面全屏高度
console.log('页面全屏宽度:', fullScreenWidth);
console.log('页面全屏高度:', fullScreenHeight);
}).exec();
},
fail: function(error) {
console.log('获取系统信息失败', error);
}
});
微信小程序如何获取页面全屏宽高
最新推荐文章于 2024-06-20 17:25:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)