Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
970 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 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...