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)文章
vue單頁應(yīng)用加百度統(tǒng)計(jì)代碼(親測有效)
這篇文章主要介紹了vue單頁應(yīng)用加百度統(tǒng)計(jì)代碼的解決方法,需要的朋友參考下吧2018-01-01
uni-app獲取當(dāng)前環(huán)境信息的方法
uni-aap提供了異步(uni.getSystemInfo)和同步(uni.getSystemInfoSync)的2個(gè)API獲取系統(tǒng)信息,這篇文章主要介紹了uni-app獲取當(dāng)前環(huán)境信息的相關(guān)知識(shí),需要的朋友可以參考下2022-11-11
Vue配置marked鏈接添加target="_blank"的方法
這篇文章主要介紹了Vue配置marked鏈接添加target="_blank"的方法,文中給大家提到了vue實(shí)現(xiàn)類似target="_blank"打開新窗口的代碼,感興趣的朋友參考下吧2019-07-07
Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù)
這篇文章主要介紹了Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08

