收藏
回答

wx.request 返回数据不是json格式?

wx.request({

返回数据不是json格式

   console.log(res.data,'控制台输出res.data'); 

{"ggtop":[{"id":"10","name":"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170524\/1495588800716222.jpg"},{"id":"5","name":"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170525\/1495684434521009.jpg"},{"id":"2","name":"%E6%BB%9A%E5%8A%A8%E5%B9%BF%E5%91%8A%E5%9B%BE2","photo":"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170524\/1495589027693993.jpg"},


实际上我要的返回数据应该是

{ggtop:[{id:"10",name:"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD",photo:"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170524\/1495588800716222.jpg"},{id:"5",name:"%E9%A6%96%E9%A1%B5%E8%BD%AE%E6%92%AD",photo:"https:\/\/62222.qicp.vip\/Data\/UploadFiles\/adv\/20170525\/1495684434521009.jpg"}


请问,怎么办?

直接转换JSON.parse(res.data);会出错



回答关注问题邀请回答
收藏

4 个回答

登录 后发表内容
问题标签