问题标题:chooseAvatar 弹窗在横屏跳转到竖屏页面后首次打开时位置溢出
问题描述:
在横屏小程序中,从横屏页面跳转到竖屏页面(pageOrientation: "portrait")后,首次点击 open-type="chooseAvatar" 按钮时,头像选择弹窗会溢出屏幕外,似乎仍按横屏尺寸计算。第二次进入该页面时,问题消失。
复现步骤:
1. 小程序主页面设置为横屏模式
2. 跳转到竖屏页面(pageOrientation: "portrait")
3. 首次进入时,立即点击 open-type="chooseAvatar" 按钮
4. 观察:头像选择弹窗溢出屏幕外
最小复现代码:
// index.json
{
"pageOrientation": "portrait"
}
// index.wxml
<button open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image src="{{avatarUrl}}" mode="aspectFill"></image>
</button>
// index.js
Page({
onLoad() {
wx.setScreenOrientation({ orientation: 'portrait' });
},
onChooseAvatar(e) {
console.log('选择头像:', e.detail.avatarUrl);
}
});
调试信息:
- 屏幕方向检测正常:{windowWidth: 390, windowHeight: 753, isPortrait: true}
- 按钮位置正确:{left: 80, top: 204, width: 184, height: 52}
- 但弹窗仍然溢出
期望行为:
chooseAvatar 弹窗应该使用当前页面的实际屏幕尺寸和方向计算位置,首次进入和后续进入行为一致。
环境信息:
- 基础库版本:3.8.12
- 微信版本:8.0.65
- 设备:iPhone13 真机 IOS版本 18.6.2

请按照链接提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。