js创建a标签下载download属性不起作用

downloadlink(){
    let x = new XMLHttpRequest();
    x.open("GET", url, true);
    x.responseType = "blob";
    x.onload = function (e) {
      const url = window.URL.createObjectURL(x.response);
      const a = document.createElement("a");
      a.href = url;
      a.download = fileName;
      a.click();
    };
    x.send();
posted @ 2021-07-03 19:03  懒惰ing  阅读(1172)  评论(0编辑  收藏  举报