​wx.openDocument() 打不开pdf文档,文件下载好了没反应?

发布于 6 年前作者 liuwei1817 次浏览最后编辑 6 年前来自 issues

wx.downloadFile({

url: https://www.xxxx.com/api/wechat/nfiles/download?fileid=1&userid=1, //仅为示例,并非真实的资源

success: function (res) {

        // this.setData({

        //   files: res.tempFilePath

        // })

        wx.openDocument({

            filePath: res.tempFilePath,

            success: function (res) {

            console.log(‘打开文档成功’)

    }

})

}

文件下载好了没反应,提示unable to find app to open this type of document

2 回复
yong58
yong581 楼6 年前

解决了,必须要加fileType: “pdf” 才可打开

wx.downloadFile({

// 示例 url,并非真实存在

url: https://www.xxxx.com/api/wechat/nfiles/download?fileid=1&userid=1,

success: function (res) {

const filePath = res.tempFilePath

//更具filePath确定文档类型

console.log(‘打开’ +filePath)

wx.openDocument({

filePath: filePath,

fileType: “pdf”,

success: function (res) {

console.log(‘打开文档成功’)

}

})

}

})

juan70
juan702 楼4 年前

留眼,混点经验…