wx.request不能请求远程服务器地址,却可以请求本地服务器地址?
如下像这样请求会返回不喜欢的信息:
wx.request({ success: (re) => { //do something } }) |
success回调里会返回:
<!DOCTYPE html> < html > < head > < meta name = "viewport" content = "width=device-width, initial-scale=1, user-scalable=0" > </ head > < body > < script type = "text/javascript" > var ua = navigator.userAgent.toLowerCase(); var isWeixin = ua.indexOf('micromessenger') != -1; var isAndroid = ua.indexOf('android') != -1; var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1); if (!isWeixin) { document.head.innerHTML = '< title >抱歉,出错了</ title >< meta charset = "utf-8" >< meta name = "viewport" content = "width=device-width, initial-scale=1, user-scalable=0" >< link rel = "stylesheet" type = "text/css" href = "https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css" >'; document.body.innerHTML = '< div class = "weui_msg" >< div class = "weui_icon_area" >< i class = "weui_icon_info weui_icon_msg" ></ i ></ div >< div class = "weui_text_area" >< h4 class = "weui_msg_title" >请在微信客户端打开链接</ h4 ></ div ></ div >'; } </ script > </ body > </ html > |
我换成如下本地地址就会返回成功,获得正常数据:
wx.request({ success: (re) => { //do something } }) |
也已经设置了不校验合法域名了,也测试了远程服务器的接口地址是可以正常访问的,偏偏使用wx.request出问题,折腾了一整天了,请大伙指点一下!