vue-resourse 怎么防止表单重复提交?

nextStep() {

  let URL = this.__WEBSERVERURL__ + "/oauth/userreport/submit";
  let params = {
    name: this.customer.name,
    certNo: this.customer.idCard,
    mobile: this.customer.mobile
  };

  if (!params.name || !params.certNo || !params.mobile) {
    this.$Message.error("用户名,身份证,手机号必填!");
    return;
  }

  this.$http.post(URL, params).then(res => {
    if (res.body.code == 0) {
      console.log(res.body);
      this.$router.push({
        name: "CreditReportDetail",
        query: {
          id: res.body.reportId
        }
      });
    } else {
      this.$Message.error(res.body.msg);
    }
  });
}


=================
怎么让点了button按钮提交后 ,禁用点击防止再次提交  ,防止多次点击 
阅读 4.4k
3 个回答

设置一个变量标识,初始为false,点击提交按钮后变为true,如果为true则发出请求,请求完毕再重置为false

使用.once

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进