使用fetch实现二进制数据流的pdf预览

    fetch(url, {
      method: "POST",
      body: JSON.stringify({
        'id': brId
      })
    }).then(ret => ret.blob())
      .then(res => {
        var blob = new Blob([res], {
          type: 'application/pdf;chartset=UTF-8'
        })
        var fileURL = URL.createObjectURL(blob)
        window.open(fileURL)
      })
原文地址:https://www.cnblogs.com/Angiy/p/15157848.html