z***@outlook.com
z***@outlook.com
  • 发布:2022-12-09 11:16
  • 更新:2023-09-04 16:34
  • 阅读:876

uni.openDocument andriod 无法打开文件,打开文件提示文件不存在

分类:uni-app

报错
{"errMsg":"openDocument:fail 文件不存在","errCode":-4,"code":-4}
代码片段:复制的官方示例都会提示文件不存在

uni.downloadFile({  
                  url: 'https://example.com/somefile.pdf',  
                  success: function (res) {  
                    var filePath = res.tempFilePath;  
                    console.log(filePath);  
                    uni.openDocument({  
                      filePath: 'https://example.com/somefile.pdf',  
                      showMenu: true,  
                      success: function (res) {  
                        console.log('打开文档成功');  
                      },  
                      fail(error) {  
                        console.log(error);  
                      }  
                    });  
                  }  
                });
2022-12-09 11:16 负责人:无 分享
已邀请:
d***@prictek.com

d***@prictek.com - xxxxx

有解决这个问题吗?

  • freesoul

    这个问题解决了吗

    2024-03-04 10:20

蔡cai

蔡cai - 开发的插件:https://ask.dcloud.net.cn/article/41539

uni.openDocument下的filePath,应该使用uni.downloadFile返回的res.tempFilePath。

  • freesoul

    还是文件不存在,有解决吗

    2024-03-04 10:20

  • 蔡cai

    回复 7***@qq.com: 代码看看

    2024-03-04 15:45

要回复问题请先登录注册