diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx index f62d35e5d2..e2efa6b8bc 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx @@ -182,7 +182,7 @@ const isNeedLayout = (preImageInfo: PreImageInfo): boolean => { isPercent(bp[1]) || isPercent(bp[3]) || isDiagonalAngle(linearInfo) || - (type === 'linear' && (isPercent(height) || isPercent(width))) + (type === 'linear' && (isPercent(height) || isPercent(width)) && !(width === '100%' && height === '100%')) } const checkNeedLayout = (preImageInfo: PreImageInfo) => { @@ -315,7 +315,9 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima } else { // 数值类型 ImageStyle // 数值类型设置为 stretch imageProps.resizeMode = 'stretch' - if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) { + if (type === 'linear' && width === '100%' && height === '100%' && (!layoutWidth || !layoutHeight)) { + dimensions = StyleSheet.absoluteFillObject as unknown as { width: NumberVal, height: NumberVal } + } else if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) { // ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来 // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。 dimensions = {