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';

即可解决!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.duanlonglong.com/qdjy/1017.html