当我使用window.open()时,我无法在新窗口中打开文件
我正在使用此代码打开文件,它在控制台中显示该URL但它不会在新窗口中打开它。
ft.openFile = function(id) {
FileService.download(id).then(function(resp) {
console.log(resp.headers('Content-Type'));
var blob = new Blob([resp.data], {
type: resp.headers('Content-Type')
});
var url = $window.URL || $window.webkitURL;
var fileUrl = url.createObjectURL(blob);
window.open(fileUrl);
console.log(fileUrl);
})
回答如下:
用这个:
window.open(fileUrl, '_blank'));