1、pdfjs第三方
內嵌web view
<web-view src="https://byfile.disscode.cn/pdfjs-2.8/web/viewer.html?file={{url}}"></web-view>
2、微信小程序自帶方式
通過wx.downloadFile下載pdf文件,再通過wx.openDocument展示。
toViewWx: function (e) { wx.downloadFile({ url: e.currentTarget.dataset.url,//可以是后台傳過來的路徑 success: function(res) { const filePath = res.tempFilePath wx.openDocument({ filePath: filePath, success: function(res) { //成功 } }) } }) },
3、markdown第三方
同樣是內嵌web view
<web-view src="https://byfile.disscode.cn/marked/marked.html?file={{url}}"></web-view>
第三種方式與第一種方式雷同。都可以使用。