以下为从实际打包产物整理的等价逻辑,变量名为便于阅读而重命名,并非官方源码原文。
// 5.06 正常包:零宽度时回退到屏幕宽度
const windowWidth = Math.min(
window.innerWidth,
document.documentElement.clientWidth
) || screenWidth;
// 5.24 异常包:Apple 分支没有上述兜底
const isApple = /Apple/.test(navigator.vendor);
const windowWidth = isApple
? getWindowWidth()
: Math.min(getWindowWidth(), document.documentElement.clientWidth)
|| screenWidth;
function getWindowWidth() {
return window.innerWidth;
}
相关 rpx 换算的关键逻辑(简化):
let px = Math.floor(rpxValue / 750 * windowWidth + 0.0001);
if (px === 0) {
px = pixelRatio !== 1 && isIOS ? 0.5 : 1;
}
小票原始样式的相关尺寸示例:
.goldplan { font-size: 32rpx; }
.img-80 { width: 80rpx; height: 80rpx; }
.back { width: 240rpx; padding: 20rpx 0; border-radius: 20rpx; }
1 个回复
宸理 (作者)
问题最早是在5.26版本发现的,后续降级至5.24版本也是一样的表现,再后续在5.14版本中也确认存在同问题