showPdf: function(fileId) {
uni.downloadFile({
// 下面一行时拼接预览PDF的地址!!!
url: this.$api.PDF_VIEW + fileId,
success: function(res) {
var filePath = res.tempFilePath;
if (!filePath) return
uni.openDocument({
filePath: filePath,
success: function(res) {
console.log(res);
console.log(‘打开文档成功‘);
}
});
}
});
},
PDF_VIEW: BaseUrl +‘/api/file-manage/pdf-view?fileId=‘, // 展示pdf
原文:https://www.cnblogs.com/codebook/p/12776198.html