最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

运维笔记admin8浏览0评论

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

当我使用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. 暂无评论