uni-app 微信小程序 pdf预览

html 复制代码
<div @click="getPDF">查看体检报告</div>
js 复制代码
getPDF() {
	uni.downloadFile({
		url: `${this.$baseURL}/file/download?id=${this.pdfFileId}`,//编写在线的pdf地址
		success: function(res) {
			const filePath = res.tempFilePath;
			uni.openDocument({
				filePath: filePath,
				fileType: 'pdf',//这里类型必须是pdf
				success: function(res) {
					console.log('打开PDF成功');
				},
				fail: function(res) {
					console.log('打开PDF失败', res);
				}
			})
		},
		fail: function(res) {
			console.log('下载PDF失败', res);
		}
	})
}
相关推荐
2501_916007473 分钟前
Python实现HTTPS爬虫的完整指南:使用requests、BeautifulSoup、Selenium和Scrapy
爬虫·python·ios·小程序·https·uni-app·iphone
万亿少女的梦1681 小时前
基于微信小程序、Express与MongoDB的校园失物招领系统设计
mongodb·微信小程序·node.js·express·系统设计
AI_AGENT_DEV_AI2 小时前
原生 APP(iOS / Android)的开发与上线
uni-app
小徐_233315 小时前
Wot UI 2.3.0 发布:二维码组件来了,Open Wot 与 wot-starter 同步更新
前端·微信小程序·uni-app
skiyee18 小时前
🔥 oiyo & unibest = 又新又好的 uniapp 模板
前端·uni-app
2601_953720821 天前
【计算机毕业设计】基于微信小程序的拼车服务系统设计与实现
微信小程序·小程序·课程设计
DevOpenClub1 天前
用网页快照、静态 HTML 和 PDF 转换接口构建网页归档 Agent
前端·人工智能·pdf·html
FungLeo1 天前
Taro 4 微信小程序:RootPortal CSS 变量继承问题与自建 PagePortal 解决方案
微信小程序·taro·css 变量
fthux2 天前
装闭 RenoPit 源码解析(13):生成AI装修闭坑PDF报告
人工智能·ai·pdf·开源·github
星星在线3 天前
怎么使用Python生成PDF,我开源了PDF Report Generator
python·pdf·开源