今天小编就为大家分享一篇vue解决使用$http获取数据时报错的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
在引用vue作为一个插件时,使用$http获取数据时报错
Failed to load http://****/ajaxGrainRain: Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
只需在后台加上
add_header 'Access-Control-Allow-Headers' 'DNT, X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
即可解决!
以上就是vue解决使用$http获取数据时报错的问题的详细内容,更多请关注0133技术站其它相关文章!