可以用第三方库: FileSaver.js:

    FileSaver.js is the solution to saving files on the client-side, and is perfect for web apps that generates files on the client, However if the file is coming from the server we recommend you to first try to use Content-Disposition attachment response header as it has more cross-browser compatiblity.

    推荐阅读:《这应该是你见过的最全前端下载总结》。