我正在Bootstrap
布局中制作一个razor
的菜单,但我遇到了一个简单@Html.ActionLink
,
<ul>
<li class="dropdown-header">Editorial</li>
<li><a role="menuitem" tabindex="-1" href="/Posts/">Posts</a></li>
@*<li>@Html.ActionLink("Posts", "Index", "Posts",htmlAttributes: new { role = "menuitem", tabIndex = "-1" })</li>*@
<li>@Html.ActionLink("Tags", "Index", "Tags", htmlAttributes: new { role = "menuitem", tabIndex = "-1" })</li>
<li class="divider"></li>
<li class="dropdown-header">Dropdowns</li>
<li><a href="#">Example</a></li>
<li><a href="#">Aligninment options</a></li>
<li><a href="#">Headers</a></li>
<li><a href="#">Disabled menu items</a></li>
</ul>
以下声明并不像我想要的那样工作
@Html.ActionLink("Tags", "Index", "Tags", htmlAttributes: new { role = "menuitem", tabIndex = "-1" })
这是我的渲染:
<li class="col-sm-3">
<ul>
<li class="dropdown-header">Editorial</li>
<li><a role="menuitem" tabindex="-1" href="/Posts/">Posts</a></li>
<li><a href="/?Length=4" role="menuitem" tabindex="-1">Tags</a></li>
<li class="divider"></li>
<li class="dropdown-header">Dropdowns</li>
<li><a href="#">Example</a></li>
<li><a href="#">Aligninment options</a></li>
<li><a href="#">Headers</a></li>
<li><a href="#">Disabled menu items</a></li>
</ul>
</li>
为什么 @ Html.ActionLink(&#34;标签&#34;,&#34;索引&#34;,&#34;标签&#34;,htmlAttributes:new {role =&#34; menuitem& #34;,tabIndex =&#34; -1&#34;})在<a href="/?Length=4" role="menuitem" tabindex="-1">Tags</a>
呈现?
答案 0 :(得分:0)
这可以解决问题。
@Html.ActionLink("Tags", "Index", "Tags", null, htmlAttributes: new { role = "menuitem", tabIndex = "-1" })