wx.downloadFile报错,fail url not in domain list?
发布于 3 年前 作者 yong26 14107 次浏览 来自 问答
wx.downloadFile({
        url: obj.url,//pdf地址 例如:http://**.*****.***/ceshi/demo.pdf
        success(res) {
            if (res.statusCode === 200) {
                const tempFilePath = res.filePath//返回的文件临时地址,用于后面打开本地预览所用
                wx.openDocument({
                    filePath: tempFilePath,
                    showMenu: true,
                    fileType: "pdf",
                    success: function (res) {}
                })
            } else {
                console.log(res);
                wx.showToast({"title": "协议打开失败,请重新打开"});
            }
        },
        fail(res) {
            console.log(res);
            wx.showToast({"title": "pdf文件下载失败,请重新打开"});
        }
    })

报错信息:
{errMsg: "downloadFile:fail url not in domain list"}

真机调试时,勾选 “不检验合法域名” 可以正常打开pdf文件

pdf文件地址:https://wxx.moojing.com/pdf/09162021white.pdf

后台配置的业务域名:

1 回复
https://wxx.moojing.com  这个配置downloadfile域名,你配错了
回到顶部