diff --git "a/\345\273\226\344\273\262\350\276\211/.keep" "b/\345\273\226\344\273\262\350\276\211/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\273\226\344\273\262\350\276\211/20251230MVC\346\216\247\345\210\266\345\231\250\347\261\273.md" "b/\345\273\226\344\273\262\350\276\211/20251230MVC\346\216\247\345\210\266\345\231\250\347\261\273.md" new file mode 100644 index 0000000000000000000000000000000000000000..193737f0a3d9351cac6c688cedf735fce4c35776 --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20251230MVC\346\216\247\345\210\266\345\231\250\347\261\273.md" @@ -0,0 +1,70 @@ +# 笔记 + +``` + +控制器类继承 +public class 名称 :Controller +每一个新的方法都需要在controller文件夹下新建一个同名文件 + +``` + + + + + + // 18. 完成如下任务 + - ## 题目描述:使用计算属性名动态创建对象属性----------------------------------------------------------------------------------------------------------------- + + ```html + let key ="score"; + let student = {[key]:85} + console.log(student); + ``` + + - ## 18 完成如下任务 题目描述: 使用 jQuery 获取 id 为 "demo" 的元素,并输出该元素的 jQuery 对象------------------------------------------------ + ```html + +
我是一个对象
+ + ``` + + ```html + +``` + + - ## 使用 jQuery 选择器选中所有偶数行的表格行,并为其添加背景色---------------------------------------------------------------------------------------- + + ```html + + + + + + +
第1行
第2行
第3行
第4行
+ +``` + + +// 第2、4行有背景色 +```html + +``` + + +``` \ No newline at end of file diff --git "a/\345\273\226\344\273\262\350\276\211/20251231MVC\350\247\206\345\233\276.md" "b/\345\273\226\344\273\262\350\276\211/20251231MVC\350\247\206\345\233\276.md" new file mode 100644 index 0000000000000000000000000000000000000000..b2c57ca4f49533f32ae1665bb00403d454fac7fa --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20251231MVC\350\247\206\345\233\276.md" @@ -0,0 +1,78 @@ +# 笔记 + +- 视图 +``` +是先要有一个视图文件,然后用@在主页面插入视图 + +1.视图文件 +``` +@model Product +
+

@Model.Name

+

Price: $@Model.Price

+
+``` +2. 在主页面插入视图 +主页面(如Index.cshtml)通过@Html.Partial或@await Html.PartialAsync插入视图组件: +``` +@model IEnumerable +
+ @foreach (var product in Model) + { + @await Html.PartialAsync("_Product", product) + } +
+``` + + +- ## 200题复习题 +- ## //验证jq准备完成 +```html + +``` + +// 5. 完成如下任务 + - ## 题目描述:使用 jQuery 的 .each() 方法遍历元素集合,为每个元素设置不同的内容---------------------------------------------------------------------------------------- + +```html + +
元素1
+
元素2
+
元素3
+ +``` + +```html + +``` + + +//jq事件处理 + - ## 题目描述:使用 jQuery 为按钮添加点击事件,点击时改变页面标题 + + + ```html +

原标题

+ + ``` + +```html +let $bt=$("#bt"); +$bt.click(function(){ + let t=document.getElementById("title"); + t.innerText="新标题"; +}) + +``` \ No newline at end of file diff --git "a/\345\273\226\344\273\262\350\276\211/20260104MVC\350\267\257\347\224\261\346\250\241\346\235\277.md" "b/\345\273\226\344\273\262\350\276\211/20260104MVC\350\267\257\347\224\261\346\250\241\346\235\277.md" new file mode 100644 index 0000000000000000000000000000000000000000..cdbaa90a8aafa80bc8c5b880604b6b09708b71fa --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20260104MVC\350\267\257\347\224\261\346\250\241\346\235\277.md" @@ -0,0 +1,50 @@ +# 笔记 + +``` +// 默认路由模板配置 +app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); +``` + +- ## 200题练习 +- ## 题目描述: 使用 jQuery 的 .hover() 方法为元素添加鼠标悬停效果 +// - HTML 结构: +// ```html +//
悬停我
+// ``` + - ## 输出示例: 鼠标悬停时背景变色,离开时恢复 + - +``` + +
悬停我
+ +``` + +``` +let $box=$("#box"); +$box.hover(function(){ + $box.css("background-color","red"); +},function(){ + $box.css("background-color","grey") +}) +$box.fadeOut +``` + + - ## 题目描述:使用 jQuery 事件委托,为动态添加的列表项添加点击事件 + + ```html + + + ``` + + +```html +let count=2; +$("#addBtn").click(function(){ + $("#list").append("
  • 项目"+count+"
  • "); + count++; +}) +``` diff --git "a/\345\273\226\344\273\262\350\276\211/20260105MVC\350\267\257\347\224\261.md" "b/\345\273\226\344\273\262\350\276\211/20260105MVC\350\267\257\347\224\261.md" new file mode 100644 index 0000000000000000000000000000000000000000..9b243100f42c4117b865e4eafc694a4d6c70b734 --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20260105MVC\350\267\257\347\224\261.md" @@ -0,0 +1,9 @@ +# 笔记 + + +路由要在视图view文件夹下新建一个页面‌路由(Routing)‌: + +‌功能‌:解析URL并分发请求到控制器和动作方法。 +‌位置‌:路由规则通常在App_Start文件夹中的RouteConfig.cs(如RegisterRoutes方法)定义,与视图文件夹无关。 +``` \ No newline at end of file diff --git "a/\345\273\226\344\273\262\350\276\211/20260107MVC\345\273\272\347\253\213\345\237\272\346\234\254\346\265\201\347\250\213.md" "b/\345\273\226\344\273\262\350\276\211/20260107MVC\345\273\272\347\253\213\345\237\272\346\234\254\346\265\201\347\250\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..b9ed56303c4ec9c4aaa869bed48bb2d5f909f3c3 --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20260107MVC\345\273\272\347\253\213\345\237\272\346\234\254\346\265\201\347\250\213.md" @@ -0,0 +1,36 @@ +# 笔记 + +``` +ctrl+`调出终端 +dotnet new mvc -n 项目名称 +建立项目后 +在主仓库同级路径新建readme.md文件 (跑:doenet watch git add. 存档) +在控制器file里新建控制类文件 +1.命名空间 namespace 上上级.上级 +2.新建类时需要继承控制类 :controller +在新建的控制类文件中需要建立视图函数,IActionResult如果是首页视图则命名为View. +然后return View() + +接着在视图file里也要新建视图文件夹,用控制器的前缀名称.再新建文件.cshtml(和视图函数同名) +视图文件内部初始内容: +@{ + Layout=null; +} + +从控制器向视图传递数据的三种方法 +1.ViewData (ViewDate['title']='女侠榜') +2,ViewBag (ViewBag.Nickname='过儿') +3.强关联数据; + +在Modles的文件夹里定义新girl项专门用来定义属性 +public 数据类型 名字{get;set}=null!不可为空 +public 数据类型?名称{get;set}可为空; +``` + +## 效果图 + + +## 源代码 +```html + +``` \ No newline at end of file diff --git "a/\345\273\226\344\273\262\350\276\211/20260108MVC\350\247\206\345\233\276\347\261\273\350\241\245\345\205\205.md" "b/\345\273\226\344\273\262\350\276\211/20260108MVC\350\247\206\345\233\276\347\261\273\350\241\245\345\205\205.md" new file mode 100644 index 0000000000000000000000000000000000000000..4cdd2db2bae4a394dc59d8c4da5b0904cf8c3b26 --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20260108MVC\350\247\206\345\233\276\347\261\273\350\241\245\345\205\205.md" @@ -0,0 +1,10 @@ +# 笔记 +``` +model里定义类型 +不可为空: +public 数据类型 名字{get;set;}=null!不可为空 +publilc数据类型?名字{get:set;}可为空 + + +强类型想在视图指定需要 @ 类型,如List +``` \ No newline at end of file diff --git "a/\345\273\226\344\273\262\350\276\211/20260109MVC\346\240\207\347\255\276\345\212\251\346\211\213.md" "b/\345\273\226\344\273\262\350\276\211/20260109MVC\346\240\207\347\255\276\345\212\251\346\211\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..9cbea43f27e09bf937a6d9133c29e773535bd5b2 --- /dev/null +++ "b/\345\273\226\344\273\262\350\276\211/20260109MVC\346\240\207\347\255\276\345\212\251\346\211\213.md" @@ -0,0 +1,18 @@ +# 笔记 +``` +可以用@{}在视图页面直接做控制页面的配置,写c#代码 + + +@using使用命名空间 +@model类型 指定使用类型模型 +@if(){ + +} +可以直接用c#操控引用变量 + +Taghelps MVC标签助手 帮助拿到数据提交到页面 +超链接跳转 + +可以用httpget指定页面方晖函数 +可以用httppost指定表单提交函数避免程序混乱 +``` \ No newline at end of file