Copy the entire hybrid to the
hybrid address under the first-level folder: https://download.csdn.net/download/qq_37194189/88157330
Create a pdf page for displaying pdf files
<template>
<view style="width: 100%;" >
<web-view :src="pdfUrl"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
pdfUrl:'',
htmlUrl: '/hybrid/html/web/viewer.html',
}
},
onLoad(options) {
//从A页面点击跳转传递pdf文件路径过来
let fileUrl = encodeURIComponent(options.pdfUrl) // encodeURIComponent 函数可把字符串作为 URI 组件进行编码。
this.pdfUrl= this.htmlUrl+ '?file=' + fileUrl
}
}
</script>
Add method to the file to jump
//pdf,传入pdf的url 可实现在线预览
showPdf(){
let pdfUrl= encodeURIComponent('http://rtdsoft.xxx.pdf')
uni.navigateTo({
url:'/pages/openpdf/openpdf?pdfUrl='+ pdfUrl
})
},
it's ok