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

来源:互联网 发布:电脑版淘宝微淘在哪里 编辑:程序博客网 时间:2024/06/06 03:53

     出现“不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html”这种错误一般都是因为请求的地址错误。

   wx.request(OBJECT):wx.request发起的是 HTTPS 请求。一个微信小程序,同时只能有5个网络请求连接。
   OBJECT参数说明:

   

示例代码:

wx.request({          url: 'https://www.xxxx.com.cn/xxx/xxx.php',          data: {            username:username,            userpwd:password          },          method: 'GET',          header: {             'content-type': 'application/json'          },          success:function(res) {              if(res.data.token){                  wx.navigateTo({                       url: '../content/main/main'                  })              }else{                  wx.showModal({                        title:'提示',                        content: '用户名或密码错误',                        confirmColor:'#118EDE',                        showCancel: false,                        success: function (res) {                            if (res.confirm) {                                //console.log('用户点击确定')                            }                        }                    });               return false;              }                     },          fail:function(err){            console.log(err)          }    }) 

需要注意的是:

(1)、wx.request发起的是 HTTPS 请求

(2)、客户端的 HTTPS TLS 版本为1.2,但 Android 的部分机型还未支持 TLS 1.2,所以请确保 HTTPS 服务器的 TLS 版本支持1.2及以下版本;
(3)、要注意 method 的 value 必须为大写(例如:GET);
(4)、url 中不能有端口;

(5)、域名要与微信小程序配置信息中的request合法域名相同。例如

           

              那么request请求中的URL也必须是https://xxxx.com.cn/xxxx/xxxx.php

0 0