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

今天用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就可以了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容