material-ui TextField禁用浏览器自动完成 [英] material-ui TextField disable Browser autoComplete

查看:167
本文介绍了material-ui TextField禁用浏览器自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用材料ui v0.20.0,并且必须禁止使用TextField为用户保存密码.我向TextField autocomplete ='nope'添加了道具,因为并非所有浏览器都理解autocomplete ='off'.看来最新版本的Chrome 63不接受.有时它不起作用,有时它却起作用.我不明白为什么它如此忙碌.当chrome要求保存密码时,我将其保存,然后要编辑输入时,我仍然有以下密码:

I use material ui v0.20.0 and I have to prohibit saving the password for a user with TextField. I added props to TextField autocomplete='nope' cause not all the browsers understand autocomplete='off'. It seems that the last version of Chrome 63 does not accept it. Sometimes it does not work and sometimes it does. I can not get why it works so hectic. When chrome asks to save password and I save it, and after that I want to edit input I still have this :

  <TextField
         name='userName'
         floatingLabelText={<FormattedMessage id='users.username' />}
         value={name || ''}
         onChange={(e, name) => this.changeUser({name})}
         // autoComplete='new-password'

    /> 

    <TextField
        name='password'
        floatingLabelText={<FormattedMessage id='users.passwords.new' />}
        type='password'
        value={password || ''}
        onChange={(e, password) => this.changeUser({password})}
        autoComplete='new-password'
   />

它似乎可以在Firefox(v57.0.4)

Looks like it works in Firefox(v57.0.4)

默认情况下,TextField没有autoComplete ='off'

By default TextField does not have autoComplete='off'

推荐答案

这似乎对我有用(我们正在使用具有redux形式的材料ui)

This seems to have worked for me (we are using material ui with redux form)

 <Textfield
  inputProps={{
    autocomplete: 'new-password',
    form: {
      autocomplete: 'off',
    },
  }}
  />

如果输入为type ="password,

" new-password有效 如果常规"字段以表格形式包装,则关闭"有效

"new-password" works if the input is type="password "off" works if its a regular text field wrapped in a form

这篇关于material-ui TextField禁用浏览器自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆