uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight+44
})
该api监听到的windowHeight高度需要加上44才是正确的高度

- 发布:2022-03-28 19:38
- 更新:2022-11-01 14:22
- 阅读:447
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.3.13
浏览器平台: Chrome
浏览器版本: 全部
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
预期结果:
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
实际结果:
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
uni.onWindowResize((res) => {
//监听屏幕尺寸变化
this.appW = res.size.windowWidth
this.appH = res.size.windowHeight //少了44
})
bug描述:
uni.onWindowResize 监听到的windowHeight少了44px
