亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue與.net?Core?接收List<T>泛型參數(shù)

 更新時(shí)間:2022年04月20日 12:06:49   作者:小5聊基礎(chǔ)  
這篇文章主要介紹了Vue與.net?Core?接收List<T>泛型參數(shù),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
  • Vue Element-ui axios-post請求,axios默認(rèn)請求提的Content-Type為application/json
  • .net core后端接收參數(shù)有List<T>泛型參數(shù),如何才能正確接收呢

1、不能接收到的情況

  • 前端參數(shù)值
/*請求參數(shù)值*/
var data=[]
data.push({
  id:1,
  name:'aaa'
})
data.push({
  id:2,
  name:'bbb'
})
data.push({
  id:3,
  name:'ccc'
})
  •  后端代碼
[HttpPost]
public JsonResult Data(List<entity> list)
{
    return Json(new { c = 200, m = "test" });
}
public class entity
{
    public int id { get; set; }
    public string name { get; set; }
}

2、 能接收到的情況

  • 前端參數(shù)值
/*請求參數(shù)值*/
var data={
    length:0,
    list:[]
}
var list=[]
list.push({
  id:1,
  name:'aaa'
})
list.push({
  id:2,
  name:'bbb'
})
list.push({
  id:3,
  name:'ccc'
})
data.length=list.lenght
data.list=list
  •  后端代碼
[HttpPost]
public JsonResult Data(entity entity)
{
    return Json(new { c = 200, m = "test" });
}
public class entity
{
    public int length { get; set; }
    public List<model> list { get; set; }
}
public class model
{
    public int id { get; set; }
    public string name { get; set; }
}

到此這篇關(guān)于Vue與.net Core 接收List<T>泛型參數(shù)的文章就介紹到這了,更多相關(guān)接收List<T>泛型參數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論