1, the first time, as the @ symbol, the value can correctly become empty, the second time you enter @ can become input, the value can be displayed and also follow this regular section, and then follow the regular section no matter what you enter.
parent component
<label-input readorno="false" type="text" name="" holder="" v-model="carNo" />
subcomponents
<input :type="type" :readonly="readorno=="true"?"readonly":false" :maxlength="maxlen" :placeholder="holder" v-model="nowValue" />
props:["readorno","name","type","holder","val"],
data (){
return {
value:this.val
}
},
computed:{
nowValue: {
get (){
return this.value;
},
set (val){
if(this.name == ""){
//
var reg = /^[0-9a-zA-Z]*$/g;
if(!reg.test(val)){
alert("");
val = "";
}
this.value = val.toUpperCase();
this.$emit("input", this.value);
// console.log(this.value);
}else{
this.$emit("input", val);
}
}
}
originally intended to make the input AR12@ into AR12, but no matter how to replace, this value can not be displayed in the input, please consult.