请求

formData 传参

let formData = new FormData();
formData.append("id", 11);
formData.append("name", "zhangsna");
let config = {
  headers: { 'Content-Type': 'multipart/form-data' }
}
API.post(formData,config).then()

下载文件流传参

download(params, {
  headers: {
    "Content-Type": "application/json; application/octet-stream"
  },
  responseType: "blob",
  withCredentials: true
}).then(res => {
  // blob = new Blob([xhr.data]) // 若返回的是blob,则不需要此行
  const url = URL.createObjectURL(res),
    link = document.createElement("a");
  link.style.display = "none";
  link.href = url;
  // 自定义文件名
  // link.setAttribute("download",this.getFileName());
  // 从接口获取文件名
  link.setAttribute(
    "download",
    decodeURIComponent(
      xhr.headers["content-disposition"].split("filename=")[1]
    )
  );
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
  // URL.revokeObjectURL(blob);
})