/**
* 下载文件测试
*/
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 downloads the file and opens it
Guess you like
Origin blog.csdn.net/qq_45020145/article/details/127003936
Recommended
Ranking