微信小程序打開pdf/word/excel等失敗

官方實例:

wx.downloadFile({
  // 示例 url,並非真實存在
  url: 'http://example.com/somefile.pdf',
  success: function (res) {
    const filePath = res.tempFilePath
    wx.openDocument({
      filePath: filePath,
      success: function (res) {
        console.log('打開文檔成功')
      }
    })
  }
})

實際拷貝代碼到開發者工具,工具也打不開,真機也打不開
解決辦法:
配置fileType

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章