我正在尝试Vue 2.0和axios,我有一点问题.当我尝试使用axios向post.php文件发送post请求时,$ _POST数组始终为空.
发布功能:
doPost: function() {
console.log("post in progress")
axios.post('api/post.php', {
title: 'foo',
body: 'bar',
userId: 1
})
.then(response => {
console.log(response)
console.log(response.data)
this.filter = response.data
})
.catch(e => {
this.errors.push(e)
})
}
Run Code Online (Sandbox Code Playgroud)
post.php中
<?php
header('Content-Type: application/x-www-form-urlencoded');
echo json_encode($_POST);
?>
Run Code Online (Sandbox Code Playgroud)
请求以状态200完成,但返回空对象"[]"
注意:当我将post端点更改为jsonplaceholder工具时,它工作正常.