2

ファイル ("/foo/bar") をダウンロードするように window.location を設定しています。これで、ダウンロードは google chrome で機能しますが、次の警告が表示されます。

Resource interpreted as Document but transferred with MIME type application/csv:

これらは、Google Chrome に従って設定される応答ヘッダーです。

Content-Description:File Transfer  
Content-Disposition:attachment; filename="foo.csv"  
Content-Length:29  
Content-Type:application/csv
Date:Sun, 14 Dec 2014 20:53:33 GMT  
Server:http-kit  

とにかくjs側でacceptヘッダーを設定してこの警告を省略することができるかどうかのアイデアはありますか?

4

1 に答える 1

3

アンカータグを使用できます

<a href="fileLink" download="filename">Download</a>

ダウンロード属性には、.html、.css、.js などのファイルの拡張子タイプを入力してください。

于 2014-12-15T05:24:12.943 に答える