小白请教个vue resource的问题,关于跨域
发布于 7 年前 作者 jochen2016 3463 次浏览 来自 问答
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
    return {
      test: ''
    }
  },
  created () {
    Vue.http.options.emulateJSON = true
    this.$http.get('http://localhost:8000/api/admin/login?email=admin@qq.com&password=123456').then(response => {
      if (response.body.ok === ERROR_OK) {
        this.test = response.body
      }
    }, response => {
      console.log(response)
    })
  }
报错如下XMLHttpRequest cannot load http://localhost:8000/api/admin/login?email=admin@qq.com&password=123456. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
求指教~
存在跨域问题,后来修改get为jsonp,
报错如下 login?email=admin@qq.com&password=123456&callback=_jsonponhxrcscsgl:1 Uncaught SyntaxError: Unexpected token :
回到顶部