0

我想在 textInput 上添加类似提示的内容,就像在使用 android studio 的 java 中一样,在 react native 中可以这样做吗?我知道您可以选择添加值、默认值和占位符,但它们不像提示那样工作。

坦克!

4

3 回答 3

0

您可以使用占位符道具

<TextInput 
  placeholder="Input email"
/>
于 2019-11-18T15:10:27.903 回答
0

是的,这是可能的,它被称为placeholder ,这是来自docs的示例。:

<TextInput
      style={{height: 40}}
      placeholder="Type here to translate!"
      onChangeText={(text) => this.setState({text})}
      value={this.state.text}
    />
于 2019-11-18T15:10:35.297 回答
0

您唯一需要做的就是添加一个placeholder道具。

<TextInput 
...//otherprops
 placeholder="enter your hint here"
/>

我强烈建议您在此处阅读更多有关TextInputReact Native 文档的信息

于 2019-11-18T15:11:21.030 回答