Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TextInput在secureTextEntry为true时清除文本_Javascript_React Native_React Native Textinput - Fatal编程技术网

Javascript TextInput在secureTextEntry为true时清除文本

Javascript TextInput在secureTextEntry为true时清除文本,javascript,react-native,react-native-textinput,Javascript,React Native,React Native Textinput,您好,我正在使用react native的TextInput,有一个查看或隐藏密码的eye选项。当我将secureTextEntry设置为true并在输入中键入另一个字符时,它将清除所有以前的数据并只键入该字符 这是我的密码: <TextInput ref={ref => this._password = ref} style={[style.greyTextStyle, style.textinputStyle]} placeholder={strings.PASSWORD}

您好,我正在使用react native的TextInput,有一个查看或隐藏密码的eye选项。当我将secureTextEntry设置为true并在输入中键入另一个字符时,它将清除所有以前的数据并只键入该字符

这是我的密码:

<TextInput
 ref={ref => this._password = ref}
 style={[style.greyTextStyle, style.textinputStyle]}
 placeholder={strings.PASSWORD}
 secureTextEntry={this.state.securepass}
 placeholderTextColor={color.GREY_TEXT_COLOR}
 underlineColorAndroid='transparent'
 value={this.state.password}
 onChangeText={(text) => { this.setState({ password: text }) }} />

请帮助。

我认为这是iOS的固有行为。请检查这个和这个。您可以在切换显示/隐藏密码之前尝试保存该值,然后再次设置。

在文本输入中将属性
clearTextOnFocus
设置为false可能会有所帮助

<TextInput
 clearTextOnFocus={false}
 ref={ref => this._password = ref}
 style={[style.greyTextStyle, style.textinputStyle]}
 placeholder={strings.PASSWORD}
 secureTextEntry={this.state.securepass}
 placeholderTextColor={color.GREY_TEXT_COLOR}
 underlineColorAndroid='transparent'
 value={this.state.password}
 onChangeText={(text) => { this.setState({ password: text }) }} />
this.\u password=ref}
style={[style.greyTextStyle,style.textinputStyle]}
占位符={strings.PASSWORD}
secureTextEntry={this.state.securepass}
占位符文本颜色={color.GREY\u TEXT\u color}
“透明的”
值={this.state.password}
onChangeText={(text)=>{this.setState({password:text}}}}/>

同样的问题,你解决了吗?@David,没有。我还没有找到可行的选择。
<TextInput
 clearTextOnFocus={false}
 ref={ref => this._password = ref}
 style={[style.greyTextStyle, style.textinputStyle]}
 placeholder={strings.PASSWORD}
 secureTextEntry={this.state.securepass}
 placeholderTextColor={color.GREY_TEXT_COLOR}
 underlineColorAndroid='transparent'
 value={this.state.password}
 onChangeText={(text) => { this.setState({ password: text }) }} />