当用户单击输入时如何清除 TextInput“占位符”?

Ama*_*oux 7 textinput react-native

我想知道当用户单击字段来填充文本输入时如何清除“占位符”。

这是我的文本输入:

 <TextInput 
   style={{height:40, borderColor: 'gray', borderWidth:1}}
   onChangeText={(text) => this.setStoreName(text)}
   value={this.state.storeName}
 />
Run Code Online (Sandbox Code Playgroud)

和我的构造函数:

 constructor(props) {
    super(props)
    this.state = { 
        name: "Votre nom", 
        storeName: "Le nom de votre commerce", 
        email: "Votre email", 
        address: "L'adresse de votre commerce", 
        city: "Votre ville", 
        category: "Categorie", 
        password: "Votre mot de passe"
    }
}
Run Code Online (Sandbox Code Playgroud)

先感谢您。

Moh*_*lil 3

使用placeholder带有值TextInput 占位符的属性

<TextInput 
 style={{height:40, borderColor: 'gray', borderWidth:1}}
 onChangeText={(text) => this.setStoreName(text)}
 value={this.state.storeName}
 placeholder="Le nom de votre commerce"
/>
Run Code Online (Sandbox Code Playgroud)

并在构造函数中

constructor(props) {
 super(props)
 this.state = { 
    name: "", 
    storeName: "", 
    email: "", 
    address: "", 
    city: "", 
    category: "", 
    password: ""
 }
}
Run Code Online (Sandbox Code Playgroud)