PDF 预览

  return axios({
    url: `${urlPath}${fileName}`,
    method: "GET",
    responseType: 'arraybuffer',
  }).then(res => {
    const binaryData = [res.data];
    //获取blob链接
    const pdfUrl = window.URL.createObjectURL(new Blob(binaryData, { type: 'application/pdf' }));

    window.open(pdfUrl);
  })
}

posted @ 2021-11-02 15:36  追忆枉然  阅读(30)  评论(0编辑  收藏  举报