收藏
回答

wx.downloadFile报错,fail url not in domain list?

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 个回答

  • Mr.Zhao
    Mr.Zhao
    2021-09-18
    https://wxx.moojing.com  这个配置downloadfile域名,你配错了
    


    2021-09-18
    有用
    回复
登录 后发表内容