【发布时间】:2017-10-03 20:28:38
【问题描述】:
我有一个 vue-resource 问题,导致 临时标头显示在 chrome 上,另一方面,使用 Jquery 工作没有任何问题
问题只发生在 chrome + vue-resource
复制链接
Chrome 57.0.2987 视窗 7
我没有安装 adblock 或 origin,即使在 chrome 上的访客模式下也会发生这种情况
使用 setInterval 的简单调用集
new Vue({
el: '#main',
data: {
summary: null
},
methods: {
updateSummary: function() {
/*
$.post( "summary.php", function( data ) {
if(typeof response.body.summary != 'undefined'){
this.summary = response.body.summary;
}
});
*/
this.$http.post('summary.php').then(function(response) {
if(typeof response.body.summary != 'undefined'){
this.summary = response.body.summary;
}
});
}
},
mounted: function () {
this.updateSummary();
setInterval(function () {
this.updateSummary();
}.bind(this), 2000);
}
});
https://jsfiddle.net/7vo2s8z3/1/
重现步骤
通常会在我将页面打开几个小时时发生
预期什么?
提供内容的 200 代码响应
实际发生了什么?
我收到带有这些标头的请求
请求网址:http://127.0.0.1:8080/monitor/summary.php 推荐人政策:降级时无推荐人 请求标头
显示临时标题 接受:application/json, text/plain, / 内容类型:application/json;charset=utf-8 来源:http://127.0.0.1:8080 推荐人:http://127.0.0.1:8080/monitor/ 用户代理:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 X-Requested-With:XMLHttpRequest
查看 chrome://net-internals/#events 失败的原因是
85487: URL_REQUEST http://127.0.0.1:8080/monitor/summary.php 开始时间:2017-04-18 09:38:43.826
t=29028 [st= 0] +REQUEST_ALIVE [dt=24184] --> 优先级 = “中” --> url = "http://127.0.0.1:8080/monitor/summary.php" t=29029 [st=1] +DELEGATE_INFO [dt=24183] --> delegate_blocked_by = "RedirectToFileResourceHandler" t=53211 [st=24183] 取消 --> net_error = -2 (ERR_FAILED) t=53212 [st=24184] -REQUEST_ALIVE
【问题讨论】:
-
你的 apache/nginx 日志中有什么内容吗?
-
没什么,请求没有到达 nginx
-
@Tarik 在 chrome 72 上使用 vue 和 axios,我遇到了同样的问题。未发送发布请求。但它适用于get。如何解决?
-
我没能解决它,问题源于 ajax 处于循环状态,人们让仪表板在一夜之间运行,有时会中断
标签: javascript php google-chrome vue-resource