使用剃刀的子菜单下拉菜单的简单示例

时间:2013-04-12 16:05:05

标签: html5 razor asp.net-mvc-4

我搜索网络寻找一种方法将“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>

1 个答案:

答案 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>