/**
* 下载文件测试
*/
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)
}
});
},
uniapp下载文件并打开
于 2022-09-23 09:07:41 首次发布