C#:
public int AddCart(string cityname, string count)
{
int int01 = -1;
try
{
int01 = Convert.ToInt32(count);
}
catch (Exception)
{
// 返给前端的状态码
HttpContext.Response.StatusCode = 205;
// 返回初始值
return default;
throw;
}
// 用这种方法也是可以接收前端 get 过来在地址栏的参数
/* API地址:https://localhost:44361/api/StudyCore/AddCart */
int rows = ShoppingCarts.AddCart(cityname, count);
return rows;
}
Interfaz:
ClickAdd(){
var thisVue02 = this;
this.$http.get("https://localhost:44361/api/StudyCore/AddCart?cityname="+this.ssCity.scity+"&count="+this.count+"a").then((res02)=>{
if (res02.status == 205) {
// res02.status:状态码
alert("状态是205了呀!!!")
}
if(res02.data > 0){
thisVue02.$router.push("/AddSuccess");
// alert("进来了");
}
})
}
Tome algunas notas para poder leerlas más tarde.