Open 3DMXM opened 2 years ago
ts 请求代码 function GetUser() { axios.post("/render/GetUser", { user: "111" }).then((res: any) => { console.log(res); }) }
function GetUser() { axios.post("/render/GetUser", { user: "111" }).then((res: any) => { console.log(res); }) }
PHP接收代码 public function action_GetUser(){ $user = $this->request->post("user"); $this->json([ "code"=>"00", "user"=>$user ]); }
public function action_GetUser(){ $user = $this->request->post("user"); $this->json([ "code"=>"00", "user"=>$user ]); }
请求返回 {"code":"00","user":null}
{"code":"00","user":null}
看起来你这个并不是表单形式(x-www-form-urlencoded)的post参数格式,而是json格式的 可以尝试用 $this->request->json('user') 获取看看呢
$this->request->json('user')
恩,$this->request->json('user') 可以获取到了,谢谢
ts 请求代码
function GetUser() { axios.post("/render/GetUser", { user: "111" }).then((res: any) => { console.log(res); }) }
PHP接收代码
public function action_GetUser(){ $user = $this->request->post("user"); $this->json([ "code"=>"00", "user"=>$user ]); }
请求返回
{"code":"00","user":null}