7***@qq.com
7***@qq.com
  • 发布:2024-12-19 20:40
  • 更新:2024-12-22 23:53
  • 阅读:36

【报Bug】开了screenOrientation后,安卓首页在横竖屏切换时,宽高不对。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows12

HBuilderX类型: 正式

HBuilderX版本号: 4.42

手机系统: Android

手机系统版本号: Android 15

手机厂商: 华为

手机机型: 擎云C7

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

"screenOrientation" : [
"portrait-primary",
"portrait-secondary",
"landscape-secondary",
"landscape-primary"
],

onResize() {
let _this = this;
_this.setResize();
},

setResize() {
let _this = this;
let isIOS = this.getIsIOS();
if(!isIOS){
setTimeout(function() {
const systemInfo = uni.getSystemInfoSync();
this.windowWidth = systemInfo.windowWidth;
this.windowHeight = systemInfo.windowHeight;
console.log('Window width:', this.windowWidth);
console.log('Window height:', this.windowHeight);
console.error("强行刷新")
},100);
}
},

操作步骤:

运行代码进行调试,刚进入输出值为:(竖屏)
Window width:, [Number] 818 at pages/login/login.vue:80
Window height:, [Number] 1176 at pages/login/login.vue:81
横屏后输出为:
20:39:55.208 Window width:, [Number] 1244 at pages/login/login.vue:80
20:39:55.209 Window height:, [Number] 1176 at pages/login/login.vue:81

预期结果:

运行代码进行调试,刚进入输出值为:(竖屏)
Window width:, [Number] 818 at pages/login/login.vue:80
Window height:, [Number] 1176 at pages/login/login.vue:81
横屏后输出为:
20:39:55.208 Window width:, [Number] 818 at pages/login/login.vue:80
20:39:55.209 Window height:, [Number] 1176 at pages/login/login.vue:81

实际结果:

运行代码进行调试,刚进入输出值为:(竖屏)
Window width:, [Number] 818 at pages/login/login.vue:80
Window height:, [Number] 1176 at pages/login/login.vue:81
横屏后输出为:
20:39:55.208 Window width:, [Number] 1244 at pages/login/login.vue:80
20:39:55.209 Window height:, [Number] 1176 at pages/login/login.vue:81

bug描述:

设置了screenOrientation为"portrait-primary", "portrait-secondary", "landscape-secondary", "landscape-primary"后,使用平板打开首页时,进行横竖屏切换,窗口的宽高不对。

2024-12-19 20:40 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com - 小海

是的我也是 其他页对着 首页横屏但是内容是竖屏计算的大小

1***@qq.com

1***@qq.com - 小海

只能在main.js加
plus.screen.lockOrientation("landscape-primary"); //横屏,因为项目配置的横屏可能有bug

要回复问题请先登录注册