Vue與.net?Core?接收List<T>泛型參數(shù)
更新時間:2022年04月20日 12:06:49 作者:小5聊基礎
這篇文章主要介紹了Vue與.net?Core?接收List<T>泛型參數(shù),文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
- Vue Element-ui axios-post請求,axios默認請求提的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; }
}到此這篇關于Vue與.net Core 接收List<T>泛型參數(shù)的文章就介紹到這了,更多相關接收List<T>泛型參數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vue配置marked鏈接添加target="_blank"的方法
這篇文章主要介紹了Vue配置marked鏈接添加target="_blank"的方法,文中給大家提到了vue實現(xiàn)類似target="_blank"打開新窗口的代碼,感興趣的朋友參考下吧2019-07-07
Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù)
這篇文章主要介紹了Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08

