前台去请求下载一张图片,后端通过res.download下载,返回给前台的data是乱码
data:����JFIFHH��C↵↵↵%# , #&')*)-0-(0%()(��C↵↵↵↵(((((((((((((((((((((((((((((((((((((((((((((((((((��������>..
rrMsg:"request:ok"
header:
Accept-Ranges:"bytes"
Cache-Control:"public, max-age=0"
Connection:"keep-alive"
Content-Disposition:"attachment; filename="1525056024543.jpg""
Content-Length:"10963"
Content-Type:"image/jpeg"
Date:"Mon, 30 Apr 2018 12:40:48 GMT"
ETag:"W/"2ad3-163146c2fee""
Last-Modified:"Mon, 30 Apr 2018 02:40:24 GMT"
X-Powered-By:"Express"
__proto__:Object
statusCode:200
__proto__
:
Object
下载文件别用ajax,用window.open(url),或者window.location.href=url
如果是下载的请求是post,可以给document添加form来实现