From 0c51a4dee21025edfb0cc4cf2cf580ef8c43aa3f Mon Sep 17 00:00:00 2001 From: doslin Date: Thu, 11 Jun 2026 11:44:23 +0800 Subject: [PATCH] =?UTF-8?q?pref(rn):=20=E4=BC=98=E5=8C=96=E5=85=A8?= =?UTF-8?q?=E5=B0=BA=E5=AF=B8=20linear-gradient=20=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/runtime/components/react/mpx-view.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 f8a7f0e1bc..379ceb56d0 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx @@ -155,7 +155,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) => { @@ -288,7 +288,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 = {