You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 16:26:27