加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React-Native视图使用显式设置的宽度/高度渲染,但使用0 flexBasi

发布时间:2020-12-15 20:51:23 所属栏目:百科 来源:网络整理
导读:在React-native 0.39, 我经常得到这个错误,但我不太明白为什么(指出我没有设置flexGrow的事实). 这是控制台的错误 View was rendered with explicitly set width/height but with a 0 flexBasis. (This might be fixed by changing flex: to flexGrow:) View
在React-native 0.39,

我经常得到这个错误,但我不太明白为什么(指出我没有设置flexGrow的事实).

这是控制台的错误

View was rendered with explicitly set width/height but with a 0 flexBasis. (This might be fixed by changing flex: to flexGrow:) View: <RCTShadowView: 0x6080005a02a0; viewName: RCTView; reactTag: 2608; frame: {{0,0},{nan,nan}}>

有人可以向我解释为什么这个错误被触发?

编辑:错误来自我在主视图中添加的这个样板代码:

flex: 1,// remove width and height to override fixed static size
width: null,height: null,

但是,如果有人能够反思自己的样式,或者导致我获得良好的资源,我将不胜感激:)

参考 react-native/React/Views/RCTShadowView.m,有评论
This works around a breaking change in css-layout where setting flexBasis needs to 
be set explicitly,instead of relying on flex to propagate.

    We check for it by seeing if a width/height is provided along with a flexBasis  
of 0 and the width/height is laid out as 0.

当flex没有定义的flexBasis并且width或height为零时,会触发错误.

参考react-native/Libraries/StyleSheet/LayoutPropTypes.js,我们知道flexGrow,flexShrink和flexBasis接收的数字值.

有关可视化指南,请参阅此网页A Visual Guide to CSS3 Flexbox Properties.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读