美文网首页
react native Cannot add a child

react native Cannot add a child

作者: oc123 | 来源:发表于2018-06-26 10:28 被阅读0次
在使用scrollView时,在scrollView中加入子视图,在Android模拟器上报如题错误,简直神坑,贴图如下:

Android模拟器报错截图如下:

android报错截图.png

传入scrollView的子视图代码截图如下:

传入子视图.png
viewController={<View style={{ backgroundColor: 'red', height: 100, width: Dimensions.get('window').width, flex: 1 }}> <Image style={{ width: 30, height: 30 }} source={rightImg} /> </View>}

注意贴图和上述给出的源码,View和Image之间有一个用于间隔的空格,去掉就不报错了!

另附上述viewController的子视图应传入组件格式,例如:
viewController={<Navigator />}  // Navigator 为自定义组件

解决,神坑。。。

相关文章

网友评论

      本文标题:react native Cannot add a child

      本文链接:https://www.haomeiwen.com/subject/hespyftx.html