您好,我正在使用 React Native 的 TextInput,并且有一个眼睛选项可以查看或隐藏密码。当我将 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 }) }} />
单击 eye btn 时,我切换安全文本输入
showPassword() {
this.setState({ securepass: !this.state.securepass });
if (this.state.securepass == false) {
this.setState({ passIcon: 'eye' })
} else {
this.setState({ passIcon: 'eye-off' })
}
}
请帮忙。