ReactNative:TextInput在FlexLayout中消失

时间:2016-03-02 09:34:05

标签: react-native

我正在学习本机反应,当我尝试在flex布局中使用TextInput组件时,它会消失。

index.android.js

//....
render(){
    return (
        <View style={  {flex:1,flexDirection:'row'}}>
            <TextInput placeholder="test"/>
        </View>
    )
}

//....

我很困惑。

2 个答案:

答案 0 :(得分:4)

我尝试设置TextInput的高度,但它不起作用。 我最终成功地将宽度或{flex:1}设置为TextInput。 我认为,当parant容器设置为{flexDirection:“row”}时,TextInput的宽度为0,所以我看不到它。默认情况下,父容器的flex方向为'column',TextInput Element调整自身的{flex:1}以填充父容器。

答案 1 :(得分:2)

您需要在TextInput上设置高度:

<TextInput placeholder="test" style={{ height:60 }} />
相关问题