Vue與.net?Core?接收List<T>泛型參數(shù)
- Vue Element-ui axios-post請(qǐng)求,axios默認(rèn)請(qǐng)求提的Content-Type為application/json
- .net core后端接收參數(shù)有List<T>泛型參數(shù),如何才能正確接收呢
1、不能接收到的情況
- 前端參數(shù)值
/*請(qǐng)求參數(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ù)值
/*請(qǐng)求參數(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)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue單頁(yè)應(yīng)用加百度統(tǒng)計(jì)代碼(親測(cè)有效)
這篇文章主要介紹了vue單頁(yè)應(yīng)用加百度統(tǒng)計(jì)代碼的解決方法,需要的朋友參考下吧2018-01-01
vue中格式化時(shí)間過(guò)濾器代碼實(shí)例
這篇文章主要介紹了vue格式化時(shí)間過(guò)濾器,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
Vue+OpenLayer為地圖添加風(fēng)場(chǎng)效果
這篇文章主要為大家展示了一個(gè)demo,即利用Vue和OpenLayer在地圖上面添加風(fēng)場(chǎng)效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2022-04-04
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"打開(kāi)新窗口的代碼,感興趣的朋友參考下吧2019-07-07
Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù)
這篇文章主要介紹了Vue如何根據(jù)id在數(shù)組中取出數(shù)據(jù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08

