下载文件使用form表单提交方法

·  阅读 447
  let baseURL = "120.23.23.23";
  const pData = {
    customerName: this.customerName,
    overdueType: this.overdueType
  };
  let formData = {};
  formData.accessToken = this.token;
  formData.customerName = pData.customerName;
  formData.overdueType = pData.overdueType;
  let form = document.createElement("form");
  form.setAttribute(
    "action",
    `${baseURL}/insidetrade/erp/erp-receivable/download`
  );
  form.setAttribute("method", "post");
  for (var i in formData) {
    let input = document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", i);
    input.setAttribute("value", formData[i]);
    form.appendChild(input);
  }
  let body = document.getElementsByTagName("body")[0];
  body.appendChild(form);
  form.submit();
  body.removeChild(form);
复制代码
分类:
前端
标签:
分类:
前端
标签:
收藏成功!
已添加到「」, 点击更改