JS
axios.post('http://localhost/comments/post.php', {
a: 10
}).then(res => {
console.log(res)
})
php
<?php
//json头
header("Content-type: application/json");
//跨域
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: *");
//CORS
header("Access-Control-Request-Methods:GET, POST, PUT, DELETE, OPTIONS");
header('Access-Control-Allow-Headers:x-requested-with,content-type,test-token,test-sessid');//注意头部自定义参数不要用下划线
// $a = $_POST['a'];
$a = json_decode($HTTP_RAW_POST_DATA);
print_r($a->a);