问题如图蓝色默认填充色
原因分析:浏览器默认填充色是由浏览器的自动填充功能出发的,常见于账号密码输入框。当浏览器检测到输入框的类型为password或username的时候,会自动填充历史记录并添加默认的样式(如蓝色的填充背景)。
element-ui的输入框虽然做了样式隔离,但是浏览器原生行为会覆盖部分的样式

方法一:禁用是自动填充
通过设置autocomplete=“off”去组织浏览器的自动填充行为
方法二:针对不同浏览器的填充色,可使用CSS强制覆盖背景色和阴影
.deepStyle {
box-sizing: border-box;
::v-deep {
.el-input__inner {
background-color: rgba(255, 255, 255, 0) !important;
}
.el-input__inner:-webkit-autofill {
transition: background-color 5000s ease-in-out 0s;
-webkit-text-fill-color: #fff !important;
}
.el-input__inner:-webkit-autofill:focus {
-webkit-text-fill-color: #333 !important;
}
}
}
方法三:动态生成随机属性名
通过随机化输入框的name属性干扰浏览器识别:
<el-input
:name="'random-' + Math.random()"
type="password"
></el-input>
1094

被折叠的 条评论
为什么被折叠?



