修改理由:

缩进

此投稿已在 4年前 合并。

内容修改:

红色背景 为原始内容

绿色背景 为新增或者修改的内容

OldNewDifferences
2525```
2626<?php
2727if($_GET){
28  echo json_encode(['method'=>'get', 'params'=>$_GET]);
 28  echo json_encode(['method'=>'get', 'params'=>$_GET]);
2929} else if($_POST){
30  echo json_encode(['method'=>'post', 'params'=>$_POST]);
 30  echo json_encode(['method'=>'post', 'params'=>$_POST]);
3131} else {
32  echo 'unknow method';
 32  echo 'unknow method';
3333}
3434```
3535
 
3737### 1. 执行 GET 请求
3838```
3939axios.get('http://localhost/test.php?id=123')
40  .then(response => console.log(response.data)) //请求的返回结果存放在response.data
 40 .then(response => console.log(response.data)) // 请求的返回结果存放在response.data
4141   .catch(error => console.log(error))
42 或者如果拼接的参数比较多时可以这样传参
 42
 43// 或者如果拼接的参数比较多时可以这样传参
4344axios.get('http://localhost/test.php', {
4445           params: {
4546               id: 123,