【问题标题】:React Native - Label on top of InputReact Native - 输入顶部的标签
【发布时间】:2021-11-04 06:38:39
【问题描述】:

我找不到如何在输入顶部添加标签。

         <label > Constructor Name</label>
        <TextInput style={styles.inputs}></TextInput>

当我这样做时,它并没有团结起来。在响应式样式中,标签和输入将彼此分开。我怎样才能粘住它们?

【问题讨论】:

  • 您的要求是什么?你想让他们在同一行吗?你也应该使用文本而不是标签
  • 为什么要为标签添加文字?
  • React Native 中没有标签组件

标签: html react-native layout label


【解决方案1】:

您可以像这样为文本输入制作单独的组件 发送占位符道具,它将在 textInput 之前显示文本。

<View style={{}}>
  <Text style={{color: 'white', fontWeight: 'bold', fontSize: 15, marginBottom: 5}}>{props.placeholder}</Text>
  <TextInput
    mode="outlined"
    ref={textInput}
    label={props.label || 'Email'}
    secureTextEntry={secureTextEntry}
    onChangeText={(text) => setText(text)}
    returnKeyType={returnKeyType}
    onSubmitEditing={onSubmitEditing}
    multiline={multiline}
    keyboardType={keyboardType}
    value={text || value}
    style={[
      styles.inputStyle,
      inputStyle,
    ]}
  />
</View>

【讨论】:

  • 我需要在输入之上添加标签。文本将自己置于输入附近。
猜你喜欢
  • 2017-04-11
  • 1970-01-01
  • 2020-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-23
  • 2017-05-04
  • 1970-01-01
相关资源
最近更新 更多