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
1.0k views
in Technique[技术] by (71.8m points)

weex stream.fetch http请求失败,为什么?

 var stream = weex.requireModule('stream')
  export default {
    data () {
      return {
        myimg:'unknown'
      }
    },

    methods: {
      getStarCount (repo, callback) {
        return stream.fetch({
          method: 'GET',
          type: 'json',
          url: 'https://c.sevenkids.cn/yzmm/account/knowledge/ajaxOpenSerachKnowledgeList'
        }, callback)
      }
    },
    created () {
      this.getStarCount('11', res => {
        this.myimg = res.ok ?JSON.stringify(res):JSON.stringify(res)
      })
    }
  }
  

这是请求头:
Referer http://dotwe.org/raw/htmlVue/...
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8
Origin http://dotwe.org
返回结果:
{"status":-1,"ok":false,"statusText":"","data":""}

是这里引用的‘stream’ 需要自己实现吗?

 var stream = weex.requireModule('stream')

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

1 Answer

0 votes
by (71.8m points)

在native 端没问题,web由于浏览器限制有跨域问题。可在服务端处理一下,允许跨域


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

...