ant中input如果是password类型,无法修改input背景颜色

前言:ant中input如果是存在password类型,无法修改input背景颜色,一直都是#e8f0fe这个颜色,太坑了
研究了好久是internal-autofill-selected影响了背景颜色
加上

/deep/ .ant-input:-internal-autofill-selected {
  transition: background-color 5000s ease-in-out 0s !important;
  -webkit-text-fill-color: #FFF !important;
}
/deep/ .ant-input:-internal-autofill-selected {
  transition: background-color 5000s ease-in-out 0s !important;
  -webkit-text-fill-color: #FFF !important;
}

就可以修改input的背景颜色了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用ant组件库的表单校验时,错误提示的样式可以通过自定义样式来修改。具体步骤如下: 1. 在template模板,为需要校验的表单项添加`name`属性和`rules`属性,例如: ```html <template> <a-form :form="form"> <a-form-item label="用户名" name="username" :rules="[{ required: true, message: '请输入用户名' }]"> <a-input v-model="form.username"/> </a-form-item> <a-form-item label="密码" name="password" :rules="[{ required: true, message: '请输入密码' }]"> <a-input type="password" v-model="form.password"/> </a-form-item> </a-form> </template> ``` 2. 在样式,使用`::v-deep`伪类选择器来修改错误提示的样式,例如: ```css ::v-deep .ant-form-item-explain { color: red; } ``` 3. 如果需要修改某一个表单项的错误提示样式,可以给该表单项的错误提示添加一个唯一的class,然后在样式使用该class来修改样式,例如: ```html <template> <a-form :form="form"> <a-form-item label="用户名" name="username" :rules="[{ required: true, message: '请输入用户名' }]"> <a-input v-model="form.username"/> </a-form-item> <a-form-item label="密码" name="password" :rules="[{ required: true, message: '请输入密码' }]"> <a-input type="password" v-model="form.password"/> <div class="password-error">密码不能为空</div> </a-form-item> </a-form> </template> <style scoped> ::v-deep .ant-form-item-explain { color: red; } .password-error { color: blue; } </style> ``` 在上面的例子,我们为密码表单项的错误提示添加了一个class`password-error`,然后在样式使用该class来修改错误提示的颜色。这样就可以准确地修改某一个表单项的错误提示的样式了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值