want to get the value of input to judge by the length of value, but have a problem? Input is the code under the el-input of element
<el-input placeholder="" v-model="barId" clearable style="width: 70%;" v-on:input ="inputFunc" ref="barNo"></el-input>
this is the code for the layout, with ref
added at the end.inputFunc() {
console.log(this.$refs.barNo)
console.log(this.$refs.barNo.value)
const param = {
BarCode: this.barId
};
api.getbarcodeinfo(param).then(response => {
if (response.data.Success == false) {
this.$notify({
title: "",
message: response.data.Message,
type: "error",
duration: 2000
});
} else {
console.log(this.$refs.barNo.value)
// this.barId = "";
}
});
},
this is the code of vue that prints the value of input three times respectively. For the first time, console can get the value of the whole input, including the value in the input box, and the result of the second console is a null, and the third console can print out value. I don"t quite understand. I don"t know why the vue document can"t be opened today, so I"d like to ask the boss what the reason is and how to solve it. Thank you