How to fully simulate asynchronous download simulation a tag? (the timing of the pop-up frame is the same)

as mentioned above, I use the a tag to request download and asynchronous request to download, obviously pop up to save the window faster than the a tag, my side is the second pop-up window. The latter is to wait for the whole file to download and then pop-up window, because it is a response and then use blob to simulate a tag download. The two are tuned to the same api. Using vue, async request axios.

< hr >

normal a tag:

const a = document.createElement("a");
    a.href = `${Config.fileBaseURL}/download?url=${url}&fileName=${fileName}`;
    a.download = fileName;
    a.click();
< hr >

Asynchronous:

api.get(`/download?url=${url}&fileName=${fileName}`)
    .then(res => {
      const blob = new Blob([res.data], { type: "application/octet-stream" });
      const a = document.createElement("a");
      const url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = fileName;
      a.click();
      window.URL.revokeObjectURL(url);
    });
The

code is as above, and the request address is the same.
when I use fidder to grab the package, the normal a tag pop-up speed does not pop up in a second, probably because of the agent. The speed of both is basically the same.
has a great god studied it?

Mar.20,2021
Menu