方法一、
1.【template】
<input type="text" v-model="charater">
2.【script】
computed: {
charater: {
get: function () {
//获取的时候直接获取值
return this.charater;
},
set: function (value) {
//设置的时候变为小写
this.charater= value.toLowerCase();
}
}
},
方法二
<input type='text' @input="handleInput" :value="val"/>
handleInput(e){
//只能输入数字
this.val=e.target.value.replace(/[^\d]/g,'');
}