2017-02-07 34 views

回答

1

其他类似的问题预设了一个场景,其中回答有defined url,其他答案是old

对于现代的浏览器,您使用fetch你可以可以调用blob() on the returned response然后用URL.createObjectURL()创建一个临时的网址,您可以打开按正常的window.open()

完整的例子就是像

fetch(urlThatReturnsDataOpenableByBrowser) 
    .then(response => response.blob()) 
    .then(data => window.open(URL.createObjectURL(data))) 
相关问题