点击下载文件提示错误:downloadFile:fail createDownloadTask:fail url not in domain list
配置好request合法域名和downloadFile合法域名,可以在微信开发工具中:详情->域名信息中查看是否已经配置,若没有配置请登录微信公众号进行配置
handleDownloadFile = () => {
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
})
}
});
};