下载文件失败提示:downloadfile:fail url not in domain list
1.看响应数据是否成功 微信开发工具 --》Network
2.上传时一定要配置 详情->域名信息 中的request合法域名 uploadFile合法域名 downloadFile合法域名,并且均为https。
具体配置登录微信公众号中的设置即可配置
3.在这儿提示一个参数 wx.openDocument方法中fileType参数,在开发时最好加上。不然也有坑,很蛋疼。
4.微信小程序有坑:本人做的是一个打开Word功能。开发、测试环境都可以,线上环境不行。为此和官方人员交互三天未果。第四天早上不知道为什么此功能突然好用。醉醉......
贴上打开Word功能demo
//下载Word
downloadFile: function (e) {
let url = e.currentTarget.dataset.url.replace(\"http:\", \"https:\");
// url = url.replace(\"http:\", \"https:\");
console.log(\'url-----------\'+url);
wx.downloadFile({
url: url,
success: function (res) {
var filePath = res.tempFilePath;
wx.openDocument({
filePath: filePath,
fileType: \"doc\",
success: function (res) {
wx.hideLoading()
console.log(\'打开文档成功\')
},
fail: function (res) {
wx.showToast({
: \'打开失败\',
image: \'/images/icon_warn.png\',
duration: 2000
})
},
complete: function (res) {
console.log(res);
}
})
},
fail: function (res) {
console.log(\'文件下载失败\');
},
})
},
继续阅读与本文标签相同的文章
下一篇 :
易语言的QQ登录开发教学
-
windows(ECS)网卡信息不一致
2026-05-18栏目: 教程
-
ECS服务器重置密码
2026-05-18栏目: 教程
-
基于宜搭的“企业进销存”实践案例
2026-05-18栏目: 教程
-
学生时代所学的一些 C 语言知识点回顾(3)——再议指针的声明与使用
2026-05-18栏目: 教程
-
语音顶会Interspeech 论文解读|Audio Tagging with Compact Feedforward Sequential Memory Network and Audio-to-Audio Ratio Based Data Augmentation
2026-05-18栏目: 教程
