1:三元三木
根據判斷返回的值的大小 顯示顏色
:class="throwNum <= 0? '':'ys'"
2:去除表單的空格輸入 利用watch監聽
<input type="text" class="test" v-model="message">
watch: {
// 第一種方法
message: function() {
const reg= /\s/;
if(reg.test(this.message)){
this.message = this.message.replace(reg,'');
return;
}
}
// 第二種方法
message: function(val, oldVal) {
this.message= this.message.replace(/\s+/g, '');
},
}