项目需求是需要在app内预览本机文件
可是搜了好多资料也不行。
大家都是用什么方法解决的?还有就是不能吊起第三方app预览
doc、docx、xls、xlsx、ppt、pptx
<iframe v-if="isType(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'])" :src="`https://view.officeapps.live.com/op/embed.aspx?src=${url}`" width="100%" height="100%" frameBorder="0"></iframe>
txt
<iframe v-if="isType('txt')" :src="`${url}`" width="100%" height="100%" frameBorder="0"> </iframe>
pdf 使用pdfjs 手动添加上一页下一页按钮和维护currentPage 然后调取实例方法renderPage让其渲染currentPage页
另外还有个对开发者最方便 和对文件类型兼容性、用户体验性上最好的
https://api.onlyoffice.com/zh-CN/docspace/javascript-sdk/get-started/basic-concepts/
<script type="text/javascript" src="https://onlyoffice.xxx.com/web-apps/apps/api/documents/api.js"></script>
(xxx是需要运维把ONLYOFFICE DocSpace安装到服务器上)
使用的时候:new DocsAPI.DocEditor("previewFile", config);
previewFile是dom节点ID config是配置项 详情可参考官网
10 回答10.3k 阅读
3 回答11.3k 阅读✓ 已解决
2 回答11.2k 阅读✓ 已解决
5 回答4.2k 阅读✓ 已解决
2 回答11.1k 阅读✓ 已解决
4 回答2.5k 阅读✓ 已解决
3 回答4.6k 阅读✓ 已解决
参考插件市场里面的插件试试:https://ext.dcloud.net.cn/search?q=uniapp+%E5%AE%89%E5%8D%93%...