把你的下载地址前缀添加到合法域名就解决了
在调试工具里成功了是因为勾选了下面这项
下面是我的下载并打开函数
methods: {
downloadFileFn(data) {
if (this.detailsObj.currentUserBuy) {
uni.downloadFile({
url: 'https://' + data,
success(res) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function(res1) {
const savedFilePath = res1.savedFilePath;
uni.openDocument({
filePath: savedFilePath,
success: function(res) {
uni.hideLoading()
},
fail: function(res) {
console.log(res)
},
complete: function(res) {
setTimeout(uni.hideLoading(), 4000)
},
});
},
fail: function(err) {
console.log(err)
}
});
},
fail(res) {
console.log(res)
}
})
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39