微信小程序关于函数调用的小坑

来源:互联网 发布:下载pplive网络电视 编辑:程序博客网 时间:2024/05/29 16:37

下面的函数经调试发现始终返回不了数据

function getData() {return         [            {                "id": 157,                "desc": "猪肉五花肉猪肉",                "desc2": "好吃不贵好吃不贵!",                "level": "level3",                "logo": "../../images/wuhuarou.png",                "popular": 157,                "nodes": null,                "price": 10,                "count": 1            }
        ]
}

后经反复测试,发现原因竟是方括号的位置,下面的代码就是可以的

function getData() {return [            {                "id": 157,                "desc": "猪肉五花肉猪肉",                "desc2": "好吃不贵好吃不贵!",                "level": "level3",                "logo": "../../images/wuhuarou.png",                "popular": 157,                "nodes": null,                "price": 10,                "count": 1            }      ]}


0 0
原创粉丝点击