uniapp がファイルをダウンロードして開きます

/**
			 * 下载文件测试
			 */
			downLoadFile() {
				var _this = this
				uni.downloadFile({
					url: 'http://web.gdut.edu.cn/~jsxy/doc/keshitongji.xls',
					success: function(res) {
						var path = res.tempFilePath
						console.log('res', res);
						if (res.statusCode === 200) {
							// preview
							uni.openDocument({
								filePath: path,
								success: function(res) {
									console.log('打开文档成功');
									console.log(res);
								}
							});
							//文件保存
							uni.saveFile({
								tempFilePath: path,
								success: function(res) {
									_this.localPath = res.savedFilePath;
									console.log(savedFilePath)
									uni.showToast({
										title: '下载成功',
										content: savedFilePath,
										duration: 500
									});
									uni.getSavedFileList({
										success: function(res) {
											console.log(res.fileList);
										}
									});
								}
							});
						}
					},
					fail(err) {
						console.log('下载失败', err)
					}
				});
			},

おすすめ

転載: blog.csdn.net/qq_45020145/article/details/127003936