Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
974 views
in Technique[技术] by (71.8m points)

weex stream 状态码是-1 不知道为什么

<template>
  <div>
111111
  </div>
</template>
<style>

</style>
<script>
var stream = require('@weex-module/stream') || {}
var SEARCH_URL = 'https://api.github.com/search/repositories?q=language:javascript&sort=stars&order=desc&page=1'
module.exports = {
  data: {
    isLoaded: true,
    page: 1,
    loadingDisplay: 'hide',
    refreshDisplay: 'hide',
    loadingText: 'Loading...',
    items:[]
  },
  created: function () {
//    var url = SEARCH_URL
      var url = 'http://www.ssgo.com/services/manage/getManage'
    this.renderData(url)

  },
  methods: {
    renderData: function (url) {
      alert(url)
      var self = this
      stream.fetch({
        method: 'POST',
        url: url,
        type:'text'
      }, function(res) {

        try {
//          var results = res.data.items || []
          var status = res.status
          var results = res.data
          alert(status)
          alert(results)
          if (Array.isArray(results)) {
            for(var i = 0; i < results.length; i++) {
//              self.items.push(results[i])
            }
          }
        } catch(e) {}
      },function(res){

      })
    },

  }
}
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

虽然这个问题过去了很久,应该还是会有其他朋友会遇到。查看weexsdk源码,源码显示返回状态如果为-1,是因为body为空;如果stream.fetch用post方法的话,要用body传参。详情参考官网http://weex.apache.org/cn/ref...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...