1、首先定义两个不同的.null-input.el-input__inner{background-color:rgba(255,255,255,0.8);color:#525661;font-siz
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改变背景色的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
vue input value 背景色