美文网首页IT鉴赏
新浪微博H5客户端使用Vue.js的一个bug

新浪微博H5客户端使用Vue.js的一个bug

作者: Java_or_PHP | 来源:发表于2017-01-24 15:39 被阅读28次

今天用chrome打开了一个微博的链接:不靠谱的程序员代码能坑到什么程度,看看我的经历

为啥不用火狐,参见本人文章雾霾了?新浪微博H5前端的bug

评论区一片空白。F12一下,果然:

image.png

'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

这个问题在用Vue.js 的时候遇到过。似乎jQeury没有这个问题。

stackoverflow给出一些解释:

其中

If you are using PHP, try to add the following code at the beaning of the php file:

if you are using localhost, try this:

header("Access-Control-Allow-Origin: *");
if you are using external domains such as server, try this:

header("Access-Control-Allow-Origin: http://www.website.com");

新浪恰恰是PHP搞的,加一句header就可以了。

相关文章

网友评论

    本文标题:新浪微博H5客户端使用Vue.js的一个bug

    本文链接:https://www.haomeiwen.com/subject/ikizbttx.html