把你的下載地址前綴添加到合法域名就解決了
文章來源:http://www.zghlxwxcb.cn/news/detail-794009.html
在調(diào)試工具里成功了是因?yàn)楣催x了下面這項(xiàng)
文章來源地址http://www.zghlxwxcb.cn/news/detail-794009.html
下面是我的下載并打開函數(shù)
methods: {
// 下載
downloadFileFn(data) {
if (this.detailsObj.currentUserBuy) {
uni.downloadFile({
// data是路徑
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)
}
})
}
}
}
到了這里,關(guān)于【uniapp小程序下載】調(diào)用uni.uploadfile方法在調(diào)試工具里是沒有問題的,但是線上版本和體驗(yàn)版就調(diào)用不成功,真機(jī)調(diào)試也沒問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!