html52.com
我爱小程序-开发者交流社区

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

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

网友回复

滚动的蛋:

解决了,必须要加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('打开文档成功')

}

})

}

})


bibolibo:

留眼,混点经验..

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付