使用wx.opendocument在线预览文档,必须打开调试模式才能用

发布于 8 年前作者 xiuying456746 次浏览最后编辑 8 年前来自 issues
wx.downloadFile({
    url: this.resume,
    success: function(res) {
        var filePath = res.tempFilePath,
            index1 = filePath.lastIndexOf('.'),
            index2 = filePath.length,
            suffix = filePath.substring(index1 + 1, index2)
        console.log('filePath', filePath)
        wx.openDocument({
            filePath: filePath,
            fileType: suffix,
            success: function(res) {
                console.log('打开文档成功')
            },
            fail: (e) => {
                console.log(e)
            }
        })
    },
    fail: function(res) {
        console.log(res)
        console.log('文件下载失败')
    },
    complete: function(res) {}
})
0 回复
暂无回复