0
点赞
收藏
分享

微信扫一扫

day2 单机并发缓存

天际孤狼 2024-07-24 阅读 34
handlePdf(url) {
          	uni.showLoading({
					title: '加载中',
					mask: true,
				})
				wx.downloadFile({
					url: url,
					success: function(res) {
						console.log(res)
						uni.hideLoading()
						var filePath = res.tempFilePath
						uni.showLoading({
							title: '正在打开',
							mask: true,
						})
						wx.openDocument({
							filePath: filePath,
							fileType: 'pdf',
							success: function(res) {
								console.log(res)
								uni.hideLoading()
								console.log('打开文档成功')
							},
							fail: function(err) {
								uni.hideLoading()
								console.log('fail:' + JSON.stringify(err))
							},
						})
					},
					fail: function(err) {
						uni.hideLoading()
						console.log('fail:' + JSON.stringify(err))
					},
				})
},

url是文件的地址,使用wx.downloadFile将文件下载到本地,然后将文件使用wx.openDocument进行打开

举报

相关推荐

day2——

#day2

qt day2

Qt day2

RHCE Day2

React【Day2】

PTA day2

0 条评论