首页 > 语言 > JavaScript > 正文

vue里input根据value改变背景色的实例

2024-05-06 15:29:14
字体:
来源:转载
供稿:网友

1、首先定义两个不同的

.null-input .el-input__inner {background-color: rgba(255, 255, 255, 0.8); color: #525661; font-size: 16px;}.no-null-input .el-input__inner { background-color: rgba(255, 255, 255, 1); color: #524F52; font-size: 16px;}

2、根据:class 控制input的class

:class="{ 'null-input':isNullInput, 'no-null-input':!isNullInput}" @change="changeCss"

3、根据change方法判断input的值 然后控制isNullInput的值

changeCss(val) { if (val === "") { this.isNullInput = true; } else { this.isNullInput = false; } console.log(this.isNullInput); }

但是关于placeholder颜色无法改变

网上的方法试了 没有效果--网上方法:input::-webkit-input-placeholder

以上这篇vue里input根据value改变背景色的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持错新站长站。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选