当前位置:   article > 正文

uniapp保存打开文件并修改文件名_uni.opendocument修改文件名

uni.opendocument修改文件名
  1. async openPdf() {
  2. const {data: result} = await uni.$http.get('/api/user/add_pdf', {id: this.enrollId})
  3. if (result.state == 1) {
  4. // 此为文件名称,名称前需带/,如(/文档.pdf)
  5. let fileName = result.url.slice(4)
  6. wx.downloadFile({
  7. url: this.baseUrl + result.url,
  8. filePath: wx.env.USER_DATA_PATH + fileName,
  9. success(res) {
  10. const filePath = res.filePath || res.tempFilePath
  11. //下载完成自动打开文件
  12. wx.openDocument({
  13. showMenu: true,
  14. filePath,
  15. fileType: 'pdf',
  16. success: function (res) {
  17. console.log('打开文档成功')
  18. }
  19. })
  20. },
  21. fail(err) {
  22. console.log('打开文档失败', err)
  23. }
  24. })
  25. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/264145
推荐阅读
相关标签
  

闽ICP备14008679号