{"id":1087,"date":"2022-04-09T23:06:07","date_gmt":"2022-04-09T15:06:07","guid":{"rendered":"http:\/\/www.wayln.com\/?p=1087"},"modified":"2022-04-10T13:58:30","modified_gmt":"2022-04-10T05:58:30","slug":"view","status":"publish","type":"post","link":"https:\/\/www.wayln.com\/?p=1087","title":{"rendered":"View"},"content":{"rendered":"<div id=\"toc_container\" class=\"toc_transparent no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#_Layoutcshtml\"><span class=\"toc_number toc_depth_1\">1<\/span> _Layout.cshtml<\/a><\/li><li><a href=\"#_ViewStartcshtml\"><span class=\"toc_number toc_depth_1\">2<\/span> _ViewStart.cshtml<\/a><\/li><li><a href=\"#_ViewImportscshmtl\"><span class=\"toc_number toc_depth_1\">3<\/span> _ViewImports.cshmtl<\/a><\/li><li><a href=\"#PARTIAL_VIEW\"><span class=\"toc_number toc_depth_1\">4<\/span> PARTIAL VIEW<\/a><\/li><li><a href=\"#VIEW_COMPONENTS\"><span class=\"toc_number toc_depth_1\">5<\/span> VIEW COMPONENTS<\/a><ul><li><a href=\"#ViewComponents\"><span class=\"toc_number toc_depth_2\">5.1<\/span> \u5728\u9879\u76ee\u4e2d\u5efa\u7acb\u4e00\u4e2aViewComponents\u6587\u4ef6\u5939<\/a><\/li><\/ul><\/li><\/ul><\/div>\n<h1><span id=\"_Layoutcshtml\">_Layout.cshtml<\/span><\/h1>\n<pre><code class=\"language-HTML line-numbers\">&lt;!DOCTYPE html&gt;\n\n&lt;html&gt;\n&lt;head&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width\" \/&gt;\n    &lt;title&gt;@ViewBag.Title&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;div&gt;\n        @RenderBody()\n    &lt;\/div&gt;\n    &lt;hr\/&gt;\n    &lt;div&gt;\n        @RenderSection(\"bottom\", required: false);\n    &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/code><\/pre>\n<p>\u5982\u679c\u5176\u4ed6\u6587\u4ef6\u4e2d\u9700\u8981\u8bbe\u7f6ebottom\uff0c<\/p>\n<pre><code class=\"language-HTML line-numbers\">@section bottom\n{\n    &lt;div&gt;\n        &lt;a asp-action=\"Create\"&gt;\u6dfb\u52a0\u4e00\u4e2a\u5b66\u751f&lt;\/a&gt;\n&lt;\/div&gt;\n}\n<\/code><\/pre>\n<h1><span id=\"_ViewStartcshtml\">_ViewStart.cshtml<\/span><\/h1>\n<p>\u6b64\u6587\u4ef6\u4e00\u822c\u653e\u5728Views\u6587\u4ef6\u5939\u4e0b,\u5982\u679c\u653e\u5728Views\/Home\u6587\u4ef6\u5939\u4e0b\uff0c\u5219\u53ea\u5bf9Home\u6587\u4ef6\u5939\u4e2d\u7684\u89c6\u56fe\u8d77\u4f5c\u7528<\/p>\n<pre><code class=\"language-HTML line-numbers\">@{\n    Layout=\"_Layout\";\n}\n<\/code><\/pre>\n<h1><span id=\"_ViewImportscshmtl\">_ViewImports.cshmtl<\/span><\/h1>\n<p>\u589e\u52a0taghelper\u6216\u5bfc\u5165\u547d\u540d\u7a7a\u95f4\u7b49\uff0c\u7136\u540e\u5176\u4ed6\u89c6\u56fe\u90fd\u4e0d\u9700\u8981\u518d\u6dfb\u52a0\u547d\u540d\u7a7a\u95f4\u6216\u8005taghelper\u4e86<\/p>\n<pre><code class=\"language-CSharp line-numbers\">@addTagHelper \"*,Microsoft.AspNetCore.Mvc.TagHelpers\"\n<\/code><\/pre>\n<h1><span id=\"PARTIAL_VIEW\">PARTIAL VIEW<\/span><\/h1>\n<ul>\n<li>\u590d\u7528View\u4ee3\u7801<\/li>\n<li>@Html.Partial(&#8220;_PartialViewName&#8221;,data)(\u901a\u5e38\u4e0d\u7528\uff0c\u7528taghelper\u4ee3\u66ff)<\/li>\n<li>\u4f7f\u7528taghelper\u8bed\u6cd5<\/li>\n<\/ul>\n<pre><code class=\"language-HTML line-numbers\">&lt;Partial name=\"_StudentRow\" for=\"@Model.data\" \/&gt;\n<\/code><\/pre>\n<ul>\n<li>\u6ca1\u6709\u81ea\u5df1\u7684Model<\/li>\n<li>\u53ef\u4ee5\u5d4c\u5957<\/li>\n<\/ul>\n<h1><span id=\"VIEW_COMPONENTS\">VIEW COMPONENTS<\/span><\/h1>\n<ul>\n<li>\u53ef\u590d\u7528<\/li>\n<li>\u72ec\u7acb\u7ec4\u4ef6<\/li>\n<li>\u6709\u72ec\u7acb\u7684\u903b\u8f91\/\u6570\u636e<\/li>\n<li>\u76f8\u5f53\u4e8e\u8ff7\u4f60mvc\u8bf7\u6c42<\/li>\n<li>\u4e0d\u4f9d\u8d56\u4e8e\u7236\u7ea7View\u7684\u6570\u636e<\/li>\n<\/ul>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/www.wayln.com\/wp-content\/uploads\/2022\/04\/wp_editor_md_ce091a591c5ada11123669d339e3deb7.jpg\"><img decoding=\"async\" src=\"http:\/\/www.wayln.com\/wp-content\/uploads\/2022\/04\/wp_editor_md_ce091a591c5ada11123669d339e3deb7.jpg\" alt=\"\" \/><\/a><\/p>\n<h2><span id=\"ViewComponents\">\u5728\u9879\u76ee\u4e2d\u5efa\u7acb\u4e00\u4e2aViewComponents\u6587\u4ef6\u5939<\/span><\/h2>\n<ul>\n<li>\u5efa\u7acb\u4e00\u4e2a\u540d\u79f0\u4ee5ViewComponent\u7ed3\u5c3e\u7684cs\u6587\u4ef6\u7c7b<\/li>\n<li>\u7ee7\u627f\u81eaViewComponents<\/li>\n<li>\u7c7b\u4e2d\u7684\u65b9\u6cd5\u8fd4\u56deIViewComponentResult\u7c7b\u578b<\/li>\n<li>ViewComponents\u89c6\u56fe\u4e00\u822c\u653e\u5728Views\/Shared\/Components\u6587\u4ef6\u5939\u4e2d<br \/>\n\u6bd4\u5982\uff0c\u5728ViewComponents\u6587\u4ef6\u5939\u4e2d\u6709\u4e00\u4e2aWelcomViewComponent\u7c7b\uff0c\u5219\u89c6\u56fe\u5bf9\u5e94Views\/Shared\/Components\/Welcom\u6587\u4ef6\u5939\u4e0b\u7684<\/li>\n<li>\u5176\u4ed6\u89c6\u56fe\u8c03\u7528\u4f7f\u7528\u7684\u8bed\u6cd5<br \/>\n@await Component.InvokeAsync(&#8220;Welcome&#8221;)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 _Layout.cshtml2 _ViewStart.cshtml3 _ViewImpor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,4,2],"tags":[],"class_list":["post-1087","post","type-post","status-publish","format-standard","hentry","category-asp-net-core","category-c","category-2"],"_links":{"self":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/1087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1087"}],"version-history":[{"count":17,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/1087\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/1087\/revisions\/1104"}],"wp:attachment":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}