Material-UI自动完成和TextField触发Google自动填充 [英] Material-UI Autocomplete & TextField triggers google autocomplete

查看:328
本文介绍了Material-UI自动完成和TextField触发Google自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的项目中实现自动完成"组件,但过一段时间后从浏览器获取自动填充/自动完成功能.您知道我如何将其设置为关闭吗?

I am trying to implement the Autocomplete component into my project but am getting the autofill/autocomplete from the browser after some time. Do you know how I can set it to off ?

                        <Autocomplete

                            id="combo-box-demo"
                            options={battleRepos}
                            getOptionLabel={option => option.full_name}
                            style={{ width: 500 }}
                            renderInput={params => (
                                <TextField {...params} 
                                    label="Combo box"  
                                    variant="outlined"
                                    onBlur={event => console.log(event.target.value)}

                                    fullWidth  />
                            )}
                        />

推荐答案

更新

随着@ material-ui/core 4.7.0和@ material-ui/lab 4.0.0-alpha.33的发布,此问题现已修复,不再需要下面显示的解决方法.

With the release of @material-ui/core 4.7.0 and @material-ui/lab 4.0.0-alpha.33, this is now fixed and no longer requires the workaround shown below.

此问题已在最近的拉动请求中得到解决,但是尚未发布(将在下一个版本中发布).

This has been fixed in a recent pull request, but is not yet released (will be in the next release).

如果要在发布它之前解决此问题(可能会在几天之内),可以像下面这样设置inputProps.autoComplete = "off":

If you want to work around this prior to it being released (which will likely be within a few days), you can set inputProps.autoComplete = "off" like in the following:

<Autocomplete
    id="combo-box-demo"
    options={battleRepos}
    getOptionLabel={option => option.full_name}
    style={{ width: 500 }}
    renderInput={params => {
        const inputProps = params.inputProps;
        inputProps.autoComplete = "off";
        return (
          <TextField
            {...params}
            inputProps={inputProps}
            label="Combo box"  
            variant="outlined"
            onBlur={event => console.log(event.target.value)}
            fullWidth
          />
        );
      }
    }
/>

这篇关于Material-UI自动完成和TextField触发Google自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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