uniapp 在线预览pdf
·
uniapp中的web-view跳转到本地文件,需要在根目录下创建hybrid目录。
- 建立对应文件夹,hybrid和html文件夹;把文件复制进去;

- 然后准备一个vue页面,里面是web-view;
<template> <view> <web-view :src="url"></web-view> </view> </template> <script> export default { data () { return { url: '', // pdf链接 } }, onLoad (options) { let links = decodeURIComponent(options.links); // 设置连接地址; this.url = `/hybrid/html/pdf.html?url=${links}`; }, } </script> - 然后有需要预览pdf的页面,把pdf的地址传过来就可以了。
goReport (url) { let links = encodeURIComponent(url) uni.navigateTo({ url: '../report/report?links=' + links, }) },
更多推荐



所有评论(0)