uni.openDocument:新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx 。
注意图片预览不能用这个,其次,要预览文件必须先下载文件 uni.downloadFile 。
官方API:uni-app官网
uni.downloadFile({
url: 'https://example.com/somefile.pdf',
success: function (res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
console.log('打开文档成功');
}
});
}
});