OGeek|极客世界-中国程序员成长平台

标题: javascript - 如何在一行中创建 TextInputs? ( react 原生) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:29
标题: javascript - 如何在一行中创建 TextInputs? ( react 原生)

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



Best Answer-推荐答案


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

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

});

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4