In vue 2.0, in the environment built with vue webpack vue-resource, when running this.$http.post() locally... does it report an error?
某草草2017-07-03 11:43:26
You are reporting a cross-domain error. Please check if there is any problem with the interface first!
巴扎黑2017-07-03 11:43:26
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