我搜索网络寻找一种方法将“subItem1”和“subItem2”添加到“Home”项目菜单中(在示例代码中),但我发现使用java或复杂的razor示例。是否有更简单的方法只使用剃刀?
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</nav>
答案 0 :(得分:5)
听起来你想要以下内容?
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")
<ul>
<li>@Html.ActionLink("subItem1", "SubItemOne", "Home")</li>
<li>@Html.ActionLink("subItem2", "SubItemTwo", "Home")</li>
</ul>
</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</nav>