如何在一行中创建TextInputs? (React Native)

时间:2015-12-04 09:01:24

标签: javascript android ios react-native mobile-development

我试图在一行中创建3个TextInput,但是当我写flexDirection时:' row'它不起作用(我在设备上看不到任何文字输入)。

var SampleApp = React.createClass({
render: function() {
return (
  <View style={styles.container}>
    <View style={styles.textInputWrapper}>
      <TextInput style={styles.textInput}
      placeholder='Month'
      placeholderTextColor="#d3d3d3"
      />
    </View>
    <View style={styles.textInputWrapper}>
      <TextInput style={styles.textInput}
      placeholder='Day'
      placeholderTextColor="#d3d3d3"
      />
    </View>
    <View style={styles.textInputWrapper}>
      <TextInput style={styles.textInput}
      placeholder='Year'
      placeholderTextColor="#d3d3d3"
      />
    </View>
  </View>
  );
  }
 });

var styles = StyleSheet.create({
 container: {
 flex: 1,
 flexDirection: 'row'
}
});

1 个答案:

答案 0 :(得分:2)

您需要为每个组件添加样式。希望有所帮助。

 var styles = StyleSheet.create({
 container: {
    flex: 1,
    flexDirection: 'row'
 },
 textInputWrapper: {
     flex:1,
     height: 50,
     borderColor:'red',
     borderWidth: 2,
 },
 textInput:{
  flex:1,
 }

});