2019-06-03 React Native Keyboard

2019-06-03  本文已影响0人  KingAmo

设置KeyboardAvoidingView的属性behavior ='position'时,子元素不显示,原来当behaviorposition时,还有个contentContainerStyle属性, 文档说明如下:

image.png

A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed width and height or flex, the parent will have dimensions of 0 and the flex children will not be visible.

在父组件尺寸大于0的情况下,子组件只能填充所有可以利用的空间。但是如果父组件没有一个确定的 widthheight 或者 flex,那么父组件的尺寸就为0,如果子组件是flex组件,那么子组件将不可见。

有了以上知识的铺垫,KeyboardAvoidingView 子元素不显示的原因就显而易见了。由于behaviorposition没有设置contentContainerStyle ,当KeyboardAvoidingView的子组件为flex组件时,就看不见了

上一篇下一篇

猜你喜欢

热点阅读