【发布时间】:2020-10-07 10:59:07
【问题描述】:
代码由两个输入字段组成,如果Fullname的值大于3,则假设将initial输入字段背景更改为绿色。有没有办法做到这一点?
查看
<div id="app">
<input type="text" v-model="fullname" placeholder="Enter Full Name" @input="changeInitialColor"/>
<input type="text" v-model="initial" placeholder="On Full Name make it green"/>
</div>
脚本
new Vue({
el: "#app",
data: {
fullname:'',
inital:''
},
methods: {
changeInitialColor(){
if(this.fullname.length > 3){
console.log('Change v-model=Initial field color into green');
}
else{
console.log("Dont change color");
}
}
}
})
下面是JSFIDDLE上的代码
【问题讨论】:
标签: javascript css vue.js vuejs2 vue-component