不要在React中的chrome浏览器中自动填充用户名和密码

问题描述 投票:0回答:1

我正在开发 React 应用程序,并且遇到了 Chrome 自动填充功能的问题。当我有用户名和密码的输入字段时,Chrome 会自动填写信息,这给我的用户带来了可用性问题。出于安全和用户体验的原因,我想禁用此自动填充行为。

我尝试将 autocomplete="off" 属性添加到输入字段,但它似乎没有按预期工作。 Chrome 继续自动填充代码下方的字段enter image description here

what need to do to remove autofill autoComplete=off


    

google-chrome browser autofill
1个回答
0
投票
我认为应该能够使用输入上的自动完成属性将其关闭,您可以尝试这样的操作,通过使角色等于演示,以及您已经拥有的自动完成属性,还将自动完成设置为新密码以进行密码输入领域。

<form autocomplete="off"> <input role="presentation" type="text" name="username" autocomplete="off" /> <!--OR--> <input role="presentation" type="text" name="email" autocomplete="off" /> <input role="presentation" type="password" name="password autocomplete="new-password" /> </form>
    
© www.soinside.com 2019 - 2024. All rights reserved.