Postman测试.Net Core WebApi Post()
[HttpPost] public string Post([FromBody]LoginModel model) { if (model.Account == "longdb" && model.Pw == "123") { return "测试成功"; } return "1222kk"; }
vue.js 使用axios请求该类型接口:
this.$http.post(this.$baseUrl + "/weatherforecast", { Account: "longdb", Pw: "123" }).then(res => { console.log(res.data); res = res.data; });
Postman 填写对应参数。代码中LoginModel为类。