Vue與.net?Core?接收List<T>泛型參數(shù)
更新時間:2022年04月20日 12:06:49 作者:小5聊基礎(chǔ)
這篇文章主要介紹了Vue與.net?Core?接收List<T>泛型參數(shù),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
- 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)文章
vue2和elementUI?實現(xiàn)落日余暉登錄頁和滑塊校驗功能
這篇文章主要介紹了vue2和elementUI打造落日余暉登錄頁和滑塊校驗,本文通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06解決vue prop傳值default屬性如何使用,為何不生效的問題
這篇文章主要介紹了解決vue prop傳值default屬性如何使用,為何不生效的問題。具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09Vue3+Element-Plus?實現(xiàn)點擊左側(cè)菜單時顯示不同內(nèi)容組件展示在Main區(qū)域功能
這篇文章主要介紹了Vue3+Element-Plus?實現(xiàn)點擊左側(cè)菜單時顯示不同內(nèi)容組件展示在Main區(qū)域功能,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-01-01