uniapp 展示后端返回的 pdf 文件

操作思路: 

  触发事件时 一般是请求后 拿到pdf 的地址 

  然后通过navigator 跳转到新页面 同时页面传参url

  在新页面写一个 web-view 标签  :src = "url" 即可

 

.then(res=>{
  that.pdfUrl = res.data.data.url
  uni.navigateTo({
    url: `/xxx?url=${that.pdfUrl}`
  })
})

 

新页面  xxx.vue

<web-view :src="pdfUrl">
</web-view>

 

onLoad (e) {
  this.pdfUrl = e.url
}

这样即可

 

posted on 2022-03-01 11:56  贲风  阅读(778)  评论(0)    收藏  举报