Skip to content

Commit 14aa457

Browse files
authored
Merge pull request #2345 from didi/fix-rn-view-linear
fix(rn): 完善View组件渐变色宽高计算逻辑
2 parents 15f127f + 055881b commit 14aa457

File tree

1 file changed

+1
-1
lines changed
  • packages/webpack-plugin/lib/runtime/components/react

1 file changed

+1
-1
lines changed

packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
287287
} else { // 数值类型 ImageStyle
288288
// 数值类型设置为 stretch
289289
imageProps.resizeMode = 'stretch'
290-
if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
290+
if (type === 'linear' && (!layoutWidth || !layoutHeight) && (isPercent(width) || isPercent(height))) {
291291
// ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
292292
// 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
293293
dimensions = {

0 commit comments

Comments
 (0)