Bootstrap 下拉菜单在第一次点击后不起作用
Bootstrap DropDown menu doesn't work after first click
我的 _Layout.cshtml 中有下拉菜单,第一次单击其中一个菜单项时效果很好,例如,我会转到 http://localhost:52098/Home/ViewTable/Scottish Premiership。
如果我再次点击 URL,它会尝试将我带到 http://localhost:52098/Home/ViewTable/Home/ViewTable/Scottish Premiership
导航代码:
div class="navbar navbar-inverse navbar-fixed-top">
<ul class="nav nav-pills">
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Scotland <span class="caret"></span></a>
<ul class="dropdown-menu multi-level" role="menu">
<li role="presentation"><a role="menuitem" tabindex="-1" href="Home/ViewTable/Scottish Premiership">
Scottish Premiership
</a></li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
Scottish Championship
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1">
Scottish First Division
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1">
Scottish Second Division
</a>
</li>
</ul>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
England <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
English Premier League
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
English Championship
</a>
</li>
</ul>
</li>
</ul>
// @*@Html.MvcSiteMap().Menu(false, true, true, true, true)
@Html.MvcSiteMap().SiteMapPath()*@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav"></ul>
</div>
</div>
看起来它是从我已经在的路径 + link 上的 href 获取相对路径,而我真正想要的是绝对路径?
将“/”添加到 URLs
的开头
喜欢/Home/ViewMain/Scottish ChampionShip
而且使用
总是更好
@Url.Action("MethodName", "Controller")
例如
<a href="@Url.Action("MethodName", "Controller")"> Test</a>
在URL中传递一个参数
<a href="@Url.Action("MethodName", "Controller", new {LeagueName = "Scottish Premiership"})"> Test</a>
我的 _Layout.cshtml 中有下拉菜单,第一次单击其中一个菜单项时效果很好,例如,我会转到 http://localhost:52098/Home/ViewTable/Scottish Premiership。
如果我再次点击 URL,它会尝试将我带到 http://localhost:52098/Home/ViewTable/Home/ViewTable/Scottish Premiership
导航代码:
div class="navbar navbar-inverse navbar-fixed-top">
<ul class="nav nav-pills">
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Scotland <span class="caret"></span></a>
<ul class="dropdown-menu multi-level" role="menu">
<li role="presentation"><a role="menuitem" tabindex="-1" href="Home/ViewTable/Scottish Premiership">
Scottish Premiership
</a></li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
Scottish Championship
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1">
Scottish First Division
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1">
Scottish Second Division
</a>
</li>
</ul>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
England <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
English Premier League
</a>
</li>
<li role="presentation">
<a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
English Championship
</a>
</li>
</ul>
</li>
</ul>
// @*@Html.MvcSiteMap().Menu(false, true, true, true, true)
@Html.MvcSiteMap().SiteMapPath()*@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav"></ul>
</div>
</div>
看起来它是从我已经在的路径 + link 上的 href 获取相对路径,而我真正想要的是绝对路径?
将“/”添加到 URLs
的开头喜欢/Home/ViewMain/Scottish ChampionShip
而且使用
总是更好@Url.Action("MethodName", "Controller")
例如
<a href="@Url.Action("MethodName", "Controller")"> Test</a>
在URL中传递一个参数
<a href="@Url.Action("MethodName", "Controller", new {LeagueName = "Scottish Premiership"})"> Test</a>