首页
视频
资源
登录
原
uniapp文档在线浏览,pdf,excel,word等
862
人阅读
2024/1/24 16:45
总访问:
577625
评论:
0
收藏:
0
手机
分类:
前端
### 示例代码 ``` uni.downloadFile({ url: 'https://example.com/somefile.pdf', success: function (res) { var filePath = res.tempFilePath; uni.openDocument({ filePath: filePath, showMenu: true, success: function (res) { console.log('打开文档成功'); } }); } }); ``` ### 常见问题 ##### 打不开的问题 1. 文件地址须保证能正常打开,在浏览器中尝试是否能预览或正常下载 2. 注意文件名最好为数字字母不是中文 ##### 真机调试可以打开,体验版没反应: 1.小程序后台-开发设置中-设置downloadFile合法域名,文件访问地址的域名 ##### 文件名是一长串字符,可能需要设置一下文件名 1: ``` filePath: uni.env.USER_DATA_PATH + "/" + "隐私协议.docx", //设置文件名 ``` 2: ``` var filePath = res.filePath || res.tempFilePath ``` #### 官方文档 https://uniapp.dcloud.net.cn/api/file/file.html#opendocument
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
TeachingNote
这一生多幸运赶上过你.
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net
36篇
后端
5篇
ORM
16篇
前端
48篇
随笔
13篇
移动开发
6篇
数据库
6篇
英语
3篇
rabbitmq
1篇
.net core
5篇
unity
1篇
k8s
1篇
云服务
1篇
DDD
1篇
网络
1篇
更多
mysql
1篇
python
2篇
docker
1篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术