Skip to content

Instantly share code, notes, and snippets.

@hmmhmmhm
Last active October 16, 2021 21:19
Show Gist options
  • Select an option

  • Save hmmhmmhm/9e3e5f66ccd083bf1027b463a27d0ebb to your computer and use it in GitHub Desktop.

Select an option

Save hmmhmmhm/9e3e5f66ccd083bf1027b463a27d0ebb to your computer and use it in GitHub Desktop.
virtual file download
const url = `/component.js`;
const a = document.createElement("a");
a.href = url;
a.download = url.split("/").pop()!;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment