uniapp实现点击打开pdf文件

常用场景:登录时服务协议and隐私政策等

uni.downloadFile({
url: '文件路径(建议使用服务器地址)',
filePath: wx.env.USER_DATA_PATH + '/' + '自定义.pdf',  //修改打开文件的title
success: function(res) {
if (res.statusCode === 200) {
var filePath = res.filePath;
uni.openDocument({
filePath: filePath,
// showMenu: true, //是否有分享
success: function(res) {
console.log('打开文档成功');
}
});
}
}
});

posted @ 2022-11-30 14:29  danmo_xx  阅读(1750)  评论(0编辑  收藏  举报