1. var stream = weex.requireModule('stream')
    2. stream.fetch({
    3. method: 'POST',
    4. type: 'json',
    5. url: map.requestUrl,
    6. body: map.requestJson
    7. }, function (ret) {
    8. native.logger('request end....' + ret.status + ' ok ? ' + ret.ok)
    9. if (!ret.ok) {
    10. native.logger(map.requestUrl + ' request failed.........')
    11. } else {
    12. native.logger(map.requestUrl + ' request success........')
    13. self.listData = ret.data
    14. }
    15. }, function (response) {
    16. // progress...
    17. }
    18. )�

    当 type 被定义为 ‘json’ 或者 ‘jsonp’ 时 返回值默认为一个 JSON 对应,否则默认是 String
    JSON对象可以使用 JSON.stringify(ret.data); 转换成 String 输出日志等,不过一般情况下,JS是需要JSON对象作为参数传递的,因此直接使用 ret.data即可

    body值是请求的json字符串,而不是json对象

    Stream 相关的请求,返回具体的参数列表在此查看官方Demo查看

    注意:在JSCallback方法中,如果需要引用整个index入口js的实例,不能直接使用 this, 而是在入口方法中用类似 var self = this 的方式存储起来,方便内联回调方法各处的调用(具体的使用案例)