如何解决Vue中用$http获取数据时出现的错误问题?

更新于
2026-09-28 07:41:05
0阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计143个文字,预计阅读时间需要1分钟。

如何解决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_'。

在引用vue作为一个插件时,使用$****/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获取数据时报错的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

如何解决Vue中用$http获取数据时出现的错误问题?

标签:问题

本文共计143个文字,预计阅读时间需要1分钟。

如何解决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_'。

在引用vue作为一个插件时,使用$****/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获取数据时报错的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

如何解决Vue中用$http获取数据时出现的错误问题?

标签:问题