再用element的form表单提交时参数一直为空,找了半天最后发现是因为在提交表单后有一个还原表单的事件,这个事件写道了提交请求的方法外面,但是因为是ajax异步提交导致请求未完成参数就置空了,再此记录一下:
// 保存按钮
handleSave(updateForm){
var _this= this;
const set = this.$refs['updateForm'];
set.validate((valid) => {
if (valid) {
updataCondition(_this.updateForm).then(response => {
if(response.rel){
this.$notify({
title: '成功',
message: '审核成功!',
type: 'success',
duration:2000
});
//将表单值初始化
this.$refs['updateForm'].resetFields();
// 给父页面传递信息,关闭弹窗
PubSub.publish('dialogVisible',{flag:"check",refresh:true});
}else{
this.$notify.error({
title: '错误',
message: '审核失败!',
duration:2000
});
//将表单值初始化
this.$refs['updateForm'].resetFields();
// 给父页面传递信息,关闭弹窗
PubSub.publish('dialogVisible',{flag:"check",refresh:false});
}
});
this.isAuditTime = false;
} else {
return false;
}
});
},
主要是下面这一句,这一句要写在请求成功或失败中就行了:
//将表单值初始化
this.$refs['updateForm'].resetFields();