From cf45c1e6ca39a5da3dac11ea6a2cb7042f5a0593 Mon Sep 17 00:00:00 2001 From: xiao <2448724264@qq.com> Date: Sun, 1 Dec 2024 20:05:00 +0800 Subject: [PATCH] 1201 --- ...17\346\234\272\345\220\215\345\255\227.md" | 39 ++++++++++++ .../2024-1127-\350\247\206\345\233\276.md" | 31 ++++++++++ ...on\350\277\224\345\233\236\345\200\274.md" | 60 +++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 "\350\202\226\347\277\224/\344\275\234\344\270\232/\351\232\217\346\234\272\345\220\215\345\255\227.md" create mode 100644 "\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1127-\350\247\206\345\233\276.md" create mode 100644 "\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1128-action\350\277\224\345\233\236\345\200\274.md" diff --git "a/\350\202\226\347\277\224/\344\275\234\344\270\232/\351\232\217\346\234\272\345\220\215\345\255\227.md" "b/\350\202\226\347\277\224/\344\275\234\344\270\232/\351\232\217\346\234\272\345\220\215\345\255\227.md" new file mode 100644 index 0000000..1b51803 --- /dev/null +++ "b/\350\202\226\347\277\224/\344\275\234\344\270\232/\351\232\217\346\234\272\345\220\215\345\255\227.md" @@ -0,0 +1,39 @@ +``` + public IActionResult Baijia() + // { + + // return Content(MakeNa() + MakeMe()); + + // } + + // private string MakeNa() + // { + + // var name = "赵钱孙李周吴郑王冯陈褚卫蒋沈李凯秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常于时傅皮卞齐康伍余开发商顾孟平黄和穆萧尹"; + // var rand = new Random(); + // var index = rand.Next(1, 101); + // var a = name[index]; + + // return a.ToString(); + + // } + + // private string MakeMe() + // { + + // var name = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹"; + // var rand = new Random(); + + // var mes = rand.Next(1, 3); + // string a = ""; + // for (int i = 0; i < mes; i++) + // { + // var index = rand.Next(1, 101); + // a += name[index]; + // } + + + // return a.ToString(); + + // } +``` \ No newline at end of file diff --git "a/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1127-\350\247\206\345\233\276.md" "b/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1127-\350\247\206\345\233\276.md" new file mode 100644 index 0000000..60f4a21 --- /dev/null +++ "b/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1127-\350\247\206\345\233\276.md" @@ -0,0 +1,31 @@ +## 视图 + +### Razor语法 +1. 专业说法:模版引擎 + - 大部分时候,都是通过View()函数,传入数据给视图,这样一来,在视图中就可以通过@Model这个来获取数据 + - 实际上,可以通过声明视图模型的类型,来获得自动提示或者自动感知 +2. 使用foreach循环输出集合List + ``` + @foreach(var item in Student) + { + @item.StudentName + } + ``` + + +### 在视图上显示数据 + +1. 在视图上定义简单数据,在视图上显示 + ``` + @{ + var ao="hzhf"; + } + @ao + ``` +2. 在视图定义对象数据,集合数据 +3. 在后端传回来的集合数据 +4. 在后端传回来的对象数据 + +### 定位点标记 +1. `***` +2. `***` \ No newline at end of file diff --git "a/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1128-action\350\277\224\345\233\236\345\200\274.md" "b/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1128-action\350\277\224\345\233\236\345\200\274.md" new file mode 100644 index 0000000..d1e265e --- /dev/null +++ "b/\350\202\226\347\277\224/\347\254\224\350\256\260/2024-1128-action\350\277\224\345\233\236\345\200\274.md" @@ -0,0 +1,60 @@ +1. 基础数据类型 `int,string,List<>等等` +2. IActionResult,返回响应的状态码 + - 视图 + - 重定向(RedirectToAction("index")--在同一个控制器下) + ``` + public IActionResult List() + { + return RedirectToAction("index"); + } + + public IActionResult Index() + { + return View(); + } + ``` +3. ActionResult,是前面2个结合体,意思为既可以返回基础数据类型,也可以返回响应状态 +4. 内容响应:JsonResult,ContentResult +5. POCO(比较老的类型对象) + +### 序列化 反序列化 +``` + 序列化 反序列化 + | | + 信息--->网络--->信息 + | | + 传输媒介 网络设备 +``` + +### 基础数据类型使用 +``` + public List Index() + { + var list=new List{ + 1,2,3,4,5 + }; + return list; + } +``` + +### ActionResult使用 +``` + public ActionResult Index() + { + var i=1==3; + //判断是否成立 + if(i){ + return View(); + }else{ + return true; + } + } +``` + +### 内容响应JsonResult使用 +``` + public dynamic Index(){ + var obj=new {Name="张三",Age=19};//动态类型 + return obj; + } +``` \ No newline at end of file -- Gitee