【问题标题】:How to create TextInputs in one row? (React Native)如何在一行中创建 TextInputs? (反应原生)
【发布时间】:2016-03-09 03:40:02
【问题描述】:

我正在尝试在一行中创建 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'
}
});

【问题讨论】:

  • 请在此处包含相关代码,而不是发布链接。

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


【解决方案1】:

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

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

});

【讨论】:

    猜你喜欢
    • 2015-06-14
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2020-04-05
    • 1970-01-01
    相关资源
    最近更新 更多