当前位置:网站首页>考研题库小程序中如何实现打开考研思维导图pdf
考研题库小程序中如何实现打开考研思维导图pdf
2022-07-23 07:45:00 【mon_star°】
考研题库小程序中如何实现打开考研思维导图pdf
需求:遇到这么一个需求,考研题库小程序中,为解决分享学习资料的痛点,需要做一个资料库,所以就要实现打开考研资料思维导图pdf的功能。
问题:微信小程序中使用web-view打开pdf, IOS 可以正常打开,Android 打开为空白。
解决:使用wx.downloadFile和wx.openDocument。通过 downloadFile 获得文件路径 (本地路径),然后使用openDocument新开页面打开文档。
wx.downloadFile(Object object)
功能描述
下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径 (本地路径),单次下载允许的最大文件为 200MB。使用前请注意阅读相关说明。
注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
返回值
一个可以监听下载进度变化事件和取消下载的对象。
实现代码
wx.downloadFile({
url: 'https://.../XXX.pdf', //仅为示例,并非真实的资源
success (res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
}
}
fail (err) {
console.log(err); //失败
}
})wx.openDocument(Object object)
功能描述
新开页面打开文档。文件路径 (本地路径) ,可通过 downloadFile 获得。
实现代码
wx.openDocument({
fileType: 'pdf', // 文件类型
filePath: Path, //要打开的文件路径
success: function (res) {
console.log('打开 PDF 成功');
}
})实现效果

边栏推荐
- pingbanceshi
- ERP production operation control
- 图像处理7:测试文件
- 常用的鼠标事件和键盘事件
- KingbaseESV8R6不同隔离级下xmin的区别
- Tutorial on principles and applications of database system (038) -- index of MySQL (4): analyze index with explain command
- MGRE环境下的OSPF实验:
- Image processing 6: top level file
- Redis常用命令
- Life essays: annoying projects in 2022
猜你喜欢

Événements courants de la souris et du clavier

Unity makes simple intercepting close range artillery - how to predict the strike target
Principle and implementation of Tencent mmkv

OSPF detailed explanation (LSA) (2)

RIP实验

script之type=module

MGRE experiment

数千个数据库、遍布全国的物理机,京东物流全量上云实录 | 卓越技术团队访谈录

sdf折射反射效果记录

Xilinx FPGA一路时钟输入两个PLL
随机推荐
Elephant Swap的LaaS方案优势分析,致eToken表现强势
C: readonly and Const
利用redis实现分布式锁(单个redis)
KingbaseESV8R6不同隔离级下xmin的区别
Is it risky and safe to open an account?
MYSQL练习题:向CEO汇报的所有员工
《乔布斯传》英文原著重点词汇笔记(十五)【 chapter fourteen】
Remove title block
Image processing 5: expansion
挖财开户风险性大吗,安全吗?
Vs2019:constexpr function "qcountleadingzerobits" cannot generate constant expressions
Establish stm32f103c8t6 project template and STM32 st-link utility burn hex file
kafka消费报错coordinator unavailable.Rediscovery will be attempt redisCovery
数据库系统原理与应用教程(038)—— MySQL 的索引(四):使用 EXPLAIN 命令分析索引
Classes and objects (top)
Kingbaseesv8r6 difference of xmin under different isolation levels
freemarker
Image processing 6: top level file
pingbanceshi
[机缘参悟-50]:鬼谷子-第十二符言篇-当好领导者的艺术:守其位,观四方,洞危险,广言路,虚谏言,定规则,明赏罚,符名实,得民心。