最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

当我使用window.open()时,我无法在新窗口中打开文件

IT培训 admin 7浏览 0评论

当我使用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'));

当我使用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'));
发布评论

评论列表 (0)

  1. 暂无评论