乐趣区

关于javascript:下载txt文档

  // 下载 txt 文档
    downloadTxtFile = async () => {
        const content = await axios({
            method: "GET",
            url: downloadTempUlr,
        });
        const aLabel = document.createElement("a");
        const labelEvent = document.createEvent("MouseEvents");
        labelEvent.initEvent("click", false, false);
        aLabel.href ="data:text/plain;charset=utf-8," + encodeURIComponent(content.data);
        aLabel.download = dowmloadName;
        aLabel.target = "_blank";
        aLabel.dispatchEvent(labelEvent);
    };
退出移动版