为了账号安全,请及时绑定邮箱和手机立即绑定

小程序 wx.request请求到数据,需要怎样处理才能渲染出来?

小程序 wx.request请求到数据,需要怎样处理才能渲染出来?

wx.request向后台请求数据,后台echo json_encode($res)返回。这时小程序接收到数据,该如何处理?【注:$res是一个二维数组】wx.request请求代码  getmynh: function (sessionid){    var that = this;    wx.request({      url: 'https://xing.zhumingke.cn/index.php/home/index/getmynh',      data:{        unionid: sessionid      },      header: {        'content-type': 'application/json'      },      dataType:'json',      success:function(res){        console.log(res)        console.log(res.data)        console.log(typeof(res.data))        that.getsomething(res)      }    })  },后端返回数据代码public function getmynh(){   $unionid = I('get.unionid');   $user = M("nhuser");   $res1 = $user->where(array('unionid'=>$unionid))->find();   $phone = $res1['phone'];   $nhcont = M("nhcont");   $res2 = $nhcont->where(array('fromphone'=>'13922186065'))->field('nhcont',true)->select();   if(is_array($res2) && !empty($res2)){       $aaa = json_encode($res2);       $yt = gettype($aaa);       file_put_contents(THINK_PATH.'log/log86.txt',$yt);       echo json_encode($res2);   }else{       echo "0";   }}
查看完整描述

3 回答

?
慕粉0932367111

TA贡献1条经验 获得超0个赞

把拿回来的数据在data里面定义一个变量接收,然后在需要显示的地方将数据绑定

查看完整回答
反对 回复 2017-09-05
?
冰封灬尘世

TA贡献43条经验 获得超34个赞

唔~~ 这个问题呀!   明天再告诉你      下班!!!

查看完整回答
反对 回复 2017-09-05
  • 3 回答
  • 0 关注
  • 6359 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信