點擊下載文件提示錯誤:downloadFile:fail createDownloadTask:fail url not in domain list
配置好request合法域名和downloadFile合法域名,可以在微信開發工具中:詳情->域名信息中查看是否已經配置,若沒有配置請登錄微信公衆號進行配置
handleDownloadFile = () => {
const ticket = this.props.caseDto.caseData.ticket;
const url = `https://example.weixin.com/downloadFile` // 非真實的接口地址
Taro.downloadFile({
url: url,
success: function(res) {
var filePath = res.tempFilePath;
Taro.openDocument({
filePath: filePath,
fileType: "pdf",
success: function(res) {
Taro.showToast({
title: '文檔打開成功',
icon: 'success',
duration: 2000
})
console.log("文檔打開成功");
},
fail: function (res) {
Taro.showToast({
title: '文檔打開失敗',
icon: 'none',
duration: 2000
})
},
});
},
fail: function (res) {
Taro.showToast({
title: '文檔下載失敗',
icon: 'none',
duration: 2000
})
}
});
};