vue里input根据value改变背景色
vue里input根据value改变背景色
·
vue里input根据value改变背景色
1、首先定义两个不同的class
.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
有好的解决办法 请给我留言 谢谢
更多推荐
已为社区贡献1条内容
所有评论(0)