微信小程序 不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html

2023-02-20,,

微信小程序  不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html

友情提示:

大家在开发的时候,可以使用我的网站地址进行测试

配置 request 合法域名  https://liaolongjun.duapp.com

request 可以拷贝下面的,不用做任何修改

wx.request({
    url: 'https://liaolongjun.duapp.com/ace/https.do', 
    data: {cur:1},
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function(json){
        wx.showModal({
            title: '提示',
            content: JSON.stringify(json.data),
            success: function(res) {
                if (res.confirm) {
                    console.log('用户点击确定')
                }
            }
        })
    }
})

1、添加合法域名,如图(必须是https)

2、开发者工具- 项目- 配置信息 - 刷新

3、开发者工具-清缓存、编译

再进行 wx.request 就OK了

原创声明: 随意转载,不必注明出处,分享至上 [博客园 廖龙军 http://cnblogs.com/liaolongjun]

微信小程序 不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html的相关教程结束。

《微信小程序 不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html.doc》

下载本文的Word格式文档,以方便收藏与打印。