wx.downloadFile指定路径下载的话,安卓系统正常,IOS系统失败?
发布于 7 年前 作者 duanxiuying 14700 次浏览 来自 官方Issues
onTextTap(event){
        var posturl = this.comp('attachmentImageData').getValue('previewImageUrl');
        console.log(posturl);
        var row = this.comp('restData').getCurrentRow();
        var currenttype = this.comp('restData').getValue('fwjlx');
        var zlname = this.comp('restData').getValue('fziliaomc');
        console.log(zlname + currenttype);
        wx.downloadFile({
            url:posturl,
            filePath: wx.env.USER_DATA_PATH + zlname + currenttype,
            header: {
        'content-type': 'application/json'
          }, 
          fail: function (msg) {
            console.log('失败')
          },
            success:function(res){
              var resPath = res.filePath;                                       
              console.log(res.filePath);
                        wx.openDocument({
                          filePath: resPath,
                            success:function(res){
                                console.log('打开文档成功')
                            },
                            error: function(msg) {
                                console.log(msg)
                            }
                        })
                    }

        })

  }

2 回复

打印下具体的err

加个’/'就可以了

回到顶部