javascript - vue 2.0 uses vue+webpack+vue-resource to build an environment. When running this.$http.post() locally, does it report an error?
天蓬老师
天蓬老师 2017-07-03 11:41:26
0
2
1558

In vue 2.0, in the environment built with vue webpack vue-resource, when running this.$http.post() locally... does it report an error?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all (2)
某草草

You are reporting a cross-domain error. Please check if there is any problem with the interface first!

    巴扎黑

    It’s cross-domain, big brother.

    • Solution 1: Backend engineers are required to cooperate in setting Access-Control-Allow-Origin to *

    一定要设置 {emulateJSON: true},不然跨域不成功. 如果Web服务器无法处理编码为application/json的请求,你可以启用emulateJSON选项。启用该选项后,请求会以application/x-www-form-urlencoded作为MIME type,就像普通的HTML表单一样
    • Solution 2: this.$http.jsonp('...', { credentials: true }) Use JSONP

    Off topic: It is recommended to use axios vue-resource to officially stop maintenance in the future. It is almost the same in use

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!