【发布时间】:2019-02-19 21:55:41
【问题描述】:
实际上我的问题是我正在通过 v-on:input 检查特定值何时有效。如果该值无效,我会得到“无效数据”的响应,并且显示相同。但是,当值变为有效时,“无效数据”并没有隐藏。我怎么能这样做。
我的代码是
methods: {
checkLimit: function () {
var vm = this;
data = {};
if (this.no != '') data['no'] = this.no;
$.ajax({
url: "doc/checkNumber",
method: "POST",
data: data,
dataType: "JSON",
success: function (e) {
if (e.status == true) {
}
else{
console.log(e.msg);
vm.error = e.msg;
}
},
});
},
}
所以如果状态为假,我将显示为
<input type="text" class="form-control" v-model="orno" required=""
v-on:input="checkLimit" maxlength="3"><p>{{error}}</p>
但当 Status 为 true 时,错误消息仍然存在。如何根据更改进行更新?
【问题讨论】:
标签: vue.js vuejs2 vue-component