如何从 CUrl 下载或导出 PHP 中的 PDF 并输出到 VUE JS?

这是我的代码使用 CURL 的响应输出,我想知道如果可能的话,我将使用什么来将其响应为 JSON。或其他解决方案。

http://img1.mukewang.com/64a92be70001151004490521.jpg


肥皂起泡泡
浏览 127回答 1
1回答

侃侃无极

您可以使用 iframe 来显示 PDF 内容。在您的模板中:<iframe&nbsp; v-if="pdf"&nbsp; :src="`${pdf}`"&nbsp; width="100%">&nbsp; 'This browser does not support PDFs. Please download the PDF to view it:' <a :href="`your link to the pdf`" >'Download PDF'</a></iframe>在你的脚本中:methods: {&nbsp; &nbsp; previewPDFReport () {&nbsp; &nbsp; &nbsp; this.pdf = null&nbsp; &nbsp; &nbsp; axios.get('your link to the pdf')&nbsp; &nbsp; &nbsp; &nbsp; .then(res => res.data)&nbsp; &nbsp; &nbsp; &nbsp; .then(data => {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let blob = new Blob([data], { type: 'application/pdf' })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let url = window.URL.createObjectURL(blob)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.pdf = url&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP