javascript - 如何在一行中创建文本输入? ( react native )

标签 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'
}
});

最佳答案

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

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

});

关于javascript - 如何在一行中创建文本输入? ( react native ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34084391/

相关文章:

javascript - 在另一个内部动态编译和运行 native react 应用程序

使用 Object.create 创建的 Javascript 数组 - 不是真正的数组?

Android:我怎样才能完全中止/删除粘性广播

ios - iOS 中的 VOIP 调用集成

javascript - 无法在 jQuery UI 对话框中制作方形 Canvas

javascript - 重定向奇怪格式的 url

android - 约束布局与相对布局

iphone - 现代 b2c 应用程序的目标智能手机是什么?

ios - 使用日期格式化程序

ios - 崩溃后的 Xcode 错误