收藏
回答

微信小程序真机request失败

微信小程序在电脑的IDE上面运行时是正常的,但是在真机运行时,遇到了很奇怪的地方。

我获取到的data如下:

{"id":1,"name":"首页置顶","description":"首页轮播图","update_time":"1970-01-01 08:00:00","items":[{"key_word":"6","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-4a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"25","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-2a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"11","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-3a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"10","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-1a.png","update_time":"1970-01-01 08:00:00"}}]}


接下来我程序的语句是:

data= data.items;

我在电脑上测试得到的data数据如下:

[{"key_word":"6","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-4a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"25","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-2a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"11","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-3a.png","update_time":"1970-01-01 08:00:00"}},{"key_word":"10","type":1,"update_time":"1970-01-01 08:00:00","img":{"url":"https://www.xx.cn/zerg/public/images//banner-1a.png","update_time":"1970-01-01 08:00:00"}}]



但是在真机测试时,执行了data= data.items;语句之后;

     data就变成了undefined

我觉得很奇怪,是我哪里配置错误了吗?


开发工具调试图:

可正常获取


真机测试图:


 获取失败




最后一次编辑于  2018-08-25  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答