React Native中如何关闭确认密码输入框的“使用强密码”提示?
解决方案
直接改两处就能搞定:
- 恢复确认密码输入框的
secureTextEntry属性(你之前注释掉了,要保持密码隐藏必须开启这个) - 把确认密码框的
textContentType从"newPassword"改成"password"
修改后的完整代码
<Input secureTextEntry label="Create Password" value={password} onChangeText={setPassword} textContentType="newPassword" returnKeyType="done" leftIcon={{ type: "material-community-icons", name: "lock", color: colors.text, }} inputStyle={{ color: colors.text }} autoCapitalize="none" autoCorrect={false} /> <Input secureTextEntry // 恢复该属性,确保密码以*隐藏 label="Confirm your Password" value={confirmPassword} onChangeText={setConfirmPassword} textContentType="password" // 修改此处,关闭强密码提示 returnKeyType="done" leftIcon={{ type: "material-community-icons", name: "lock", color: colors.text, }} inputStyle={{ color: colors.text }} autoCapitalize="none" autoCorrect={false} errorMessage={localErrorMessage} />
为什么这么改
textContentType="newPassword"会向系统传递「这是创建新密码的输入框」的信号,系统因此会弹出强密码生成建议;而确认密码的作用是验证已输入的密码,设置textContentType="password"不会触发这个提示,同时secureTextEntry保证输入内容以星号隐藏。
内容的提问来源于stack exchange,提问作者Matthew
相关产品推荐
相关产品推荐

