我正在尝试使用saveAs接口,如
here所述
目前,我只担心谷歌Chrome,我使用最新的金丝雀(版本27.0.1429.0金丝雀)
Qn1:文章说.
The W3C File API includes a FileSaver interface,which makes saving
generated data as easy as saveAs(data,filename),though unfortunately
it will eventually be removed from the spec.
为什么会被删除?
Qn2:代码下方.
if (window.saveAs) { window.saveAs(blob,name); }else{ console.log("saveAs not supported") }
版画
saveAs not supported
所以chrome不支持saveAs.这不是我在网上阅读很多文章的印象.
解决方法
这是一种polyfill,正如文章中所解释的那样.您必须加载文章中列出的javascript文件,将其保存在您的资源中并链接到您的代码中:
存储库在那里:
https://github.com/eligrey/FileSaver.js
存储库在那里:
https://github.com/eligrey/FileSaver.js
但是Chrome有限制.如果文件已保存,则新的保存名称会增加:
myFile(1),然后myFile(2)等
我现在在Chrome上有一个错误,它告诉它不能打开文件,但它只是一个错误警告,因为文件很好地保存,这就是重点.