<u-button class="btn" @click="Download">下载签订合同</u-button>
<a href="http://192.168.0.200:8058/files/200200711.doc" class="btn">下载签订合同</a>
Download() {
uni.downloadFile({
url: 'http://192.168.0.200:8058/files/200200711.doc',
success: (data) => {
if (data.statusCode === 200) {
uni.saveFile({
tempFilePath: data.tempFilePath,
success: function(res) {
uni.showToast({
icon: 'none',
mask: true,
title: '文件已保存:' + res.savedFilePath,
duration: 3000,
});
setTimeout(() => {
uni.openDocument({
filePath: res.savedFilePath,
success: function(res) {
}
});
}, 3000)
}
});
}
},
fail: (err) => {
console.log(err);
uni.showToast({
icon: 'none',
mask: true,
title: '失败请重新下载',
});
},
});
},