一. axios用法

参考:

  API文档: https://www.kancloud.cn/yunye/axios/234845  或者  https://axios-http.com/zh/docs/api_intro

  GitHub: https://github.com/axios/axios

  其它博客:https://www.jianshu.com/p/d771bbc61dab

用到的服务器端接口:

第六节:前后端交互之axios用法及async异步编程
 1     [Route("api/[controller]/[action]")]
 2     [ApiController]
 3     public class FirstController : ControllerBase
 4     {
 5 
 6         /******************************************下面是测试Get请求的相关方法***************************************************/
 7 
 8         #region 下面是测试Get请求的相关方法
 9         [HttpGet]
10         public string GetInfor1(string userName, string pwd)
11         {
12             return $"{userName}+{pwd}";
13         }
14 
15         [HttpGet]
16         public string GetInfor2([FromQuery]UserInfor model)
17         {
18             return $"{model.userName}+{model.pwd}";
19         }
20         [HttpGet]
21         //加上[FromQuery]也报错
22         public string GetInfor3([FromQuery]dynamic model)
23         {
24             return $"{model.userName}+{model.pwd}";
25         }
26 
27         #endregion
28 
29     }
30     [Route("api/[controller]/[action]")]
31     [ApiController]
32     public class ThirdController : Controller
33     {
34        [HttpGet]
35         public IActionResult GetInfor4(string userName, string pwd)
36         {
37             return Json(new
38             {
39                 userName,
40                 pwd
41             });
42         }
43     }
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2021-05-24
  • 2021-10-29
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案