2017-02-14 38 views
0

我目前使用vue-resource在我的webpack项目中执行一些ajax调用。只要我让“get”调用完全正常工作,但是当我尝试发布后,我的PHP没有得到任何参数,如果我尝试执行var_dump($ _ POST),结果是一个空数组。 我的代码是很基本的:通过axios传递params后通话

let data = {req: 'req_tipe', ch: 001 }; 
this.$http.post('compute.php', data).then(response => { 
    //do stuff with response if ok    
    }, 
    response => { 
    //do stuff about error 
    }); 

我想不出什么我失踪

UPDATE: 我与爱可信和VUE,爱可信,但我的问题同样仍然存在: 无后参数

let data = {req: 'req_tipe', ch: 001 }; 
this.axios.post('compute.php', data).then(response => { 
    //do stuff with response if ok    
    }, 
    response => { 
    //do stuff about error 
    }); 
+1

vue-resource已经停用。用AXIOS替换它。 –

+0

这是我错过了! – Plastic

+0

你错过了什么? – Saurabh

回答

2

也许你可以改变像以下:

let data = new FormData(); 
data.append('req','req tipe'); 
data.append('ch','001'); 
this.axios.post('compute.php', data).then(response => { 
//do stuff with response if ok    
}, 
response => { 
//do stuff about error 
}) 

有一个尝试,或参见issues 318欲知更多信息。