遇到的问题:如下代码,安卓能正常显示pdf文件内容,ios则报错如下:

在这里插入图片描述
uniapp查看文件方法:

//点击该方法查看pdf文件
downloadFile(){
				uni.downloadFile({
					url: 'xxxxxx', //文件地址
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,//打开文件后右上角...,可以保存文件
							success: function(res) {
								console.log('打开文档成功');
							}
						});
					},
					fail: (err) => {
						console.log(err);
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '失败',
						});
					},
				});
				}

经过查询资料,原因是服务器(文件地址)缺少证书2(中间证书),查询证书地址:https://www.myssl.cn/tools/check-server-cert.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐