使用element-ui表单提交值为空的问题
2022-10-08 17:22:18
266
{{single.collect_count}}

再用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();
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}