• <tfoot id='ZN9is'></tfoot>

    • <bdo id='ZN9is'></bdo><ul id='ZN9is'></ul>

    <legend id='ZN9is'><style id='ZN9is'><dir id='ZN9is'><q id='ZN9is'></q></dir></style></legend>
    <i id='ZN9is'><tr id='ZN9is'><dt id='ZN9is'><q id='ZN9is'><span id='ZN9is'><b id='ZN9is'><form id='ZN9is'><ins id='ZN9is'></ins><ul id='ZN9is'></ul><sub id='ZN9is'></sub></form><legend id='ZN9is'></legend><bdo id='ZN9is'><pre id='ZN9is'><center id='ZN9is'></center></pre></bdo></b><th id='ZN9is'></th></span></q></dt></tr></i><div id='ZN9is'><tfoot id='ZN9is'></tfoot><dl id='ZN9is'><fieldset id='ZN9is'></fieldset></dl></div>

    1. <small id='ZN9is'></small><noframes id='ZN9is'>

        Tag Helpers - 自关闭 HTML 标签是个坏习惯?

        时间:2023-08-08
          <tbody id='0R5o3'></tbody>
      1. <small id='0R5o3'></small><noframes id='0R5o3'>

          <bdo id='0R5o3'></bdo><ul id='0R5o3'></ul>

          <i id='0R5o3'><tr id='0R5o3'><dt id='0R5o3'><q id='0R5o3'><span id='0R5o3'><b id='0R5o3'><form id='0R5o3'><ins id='0R5o3'></ins><ul id='0R5o3'></ul><sub id='0R5o3'></sub></form><legend id='0R5o3'></legend><bdo id='0R5o3'><pre id='0R5o3'><center id='0R5o3'></center></pre></bdo></b><th id='0R5o3'></th></span></q></dt></tr></i><div id='0R5o3'><tfoot id='0R5o3'></tfoot><dl id='0R5o3'><fieldset id='0R5o3'></fieldset></dl></div>
              <legend id='0R5o3'><style id='0R5o3'><dir id='0R5o3'><q id='0R5o3'></q></dir></style></legend>

                  <tfoot id='0R5o3'></tfoot>
                  本文介绍了Tag Helpers - 自关闭 HTML 标签是个坏习惯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我将 TagHelpers 合并到我的 MVC vNext 项目中,我意识到当我自行关闭 HTML 标签时它们不起作用.

                  I am incorporating TagHelpers in my MVC vNext project, and I realized they don't work when I self close the HTML tags.

                  @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
                  
                  <label asp-for="FirstName"/> <!-- self closing tag -->
                  
                  <span asp-validation-for="FirstName"/> <!-- self closing tag -->
                  

                  而且,当我放置结束标签时,我会看到正在显示的值.

                  And, insteand when I put the closing tags, I see the values being displayed.

                  <label asp-for="FirstName"></label>
                  
                  <span asp-validation-for="FirstName"></span>
                  

                  生成的 HTML

                  <label for="FirstName">FirstName</label>
                  <span class="field-validation-error" data-valmsg-for="FirstName" data-valmsg-replace="true">
                      <span id="FirstName-error" class="">The FirstName field is required</span>
                  </span>
                  

                  我想知道什么,它有什么不同?而且,自我关闭配对标签是一个坏习惯.如果您知道一些关于此设计原则的文章,请与我分享,不胜感激.

                  What I want to know, what difference does it make? And, is self closing the paired tags a bad habit. If you know some article which talks about this design principle, please share with me, it would be much appreciated.

                  推荐答案

                  它们不起作用的原因是因为MVC 标签助手不会改变元素是否自动关闭"(来自问题中的评论 #4475).

                  The reason they do not work is because the "MVC tag helpers do not change whether an element is self-closing or not" (from comments in issue #4475).

                  这是 ASP.NET 中的一个已知问题,计划是在具有结束标记的非空元素的情况下在 VS IDE 中显示警告(请参阅问题 #398).一位 ASP.NET 开发人员在问题 #1302 中评论说:

                  It is a known issue in ASP.NET and the plan is to show a warning in VS IDE under the scenario of a non-void element having an end tag (see issue #398). One of ASP.NET developers commented in issue #1302 that:

                  这是当前的设计,但我们在行为上有一些问题(打开和关闭)"

                  "this is the current design but we have a few issues (open and closed) on the behaviour"

                  这篇关于Tag Helpers - 自关闭 HTML 标签是个坏习惯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:jQuery:与在不适当的时间执行的 removeData() 冲突 下一篇:TagHelpers 基于验证属性为 LabelTagHelper 添加自定义

                  相关文章

                  最新文章

                  1. <tfoot id='12Y71'></tfoot>

                    <small id='12Y71'></small><noframes id='12Y71'>

                  2. <i id='12Y71'><tr id='12Y71'><dt id='12Y71'><q id='12Y71'><span id='12Y71'><b id='12Y71'><form id='12Y71'><ins id='12Y71'></ins><ul id='12Y71'></ul><sub id='12Y71'></sub></form><legend id='12Y71'></legend><bdo id='12Y71'><pre id='12Y71'><center id='12Y71'></center></pre></bdo></b><th id='12Y71'></th></span></q></dt></tr></i><div id='12Y71'><tfoot id='12Y71'></tfoot><dl id='12Y71'><fieldset id='12Y71'></fieldset></dl></div>

                      <legend id='12Y71'><style id='12Y71'><dir id='12Y71'><q id='12Y71'></q></dir></style></legend>
                      • <bdo id='12Y71'></bdo><ul id='12Y71'></ul>