引导下拉菜单没有第一次点击后工作 [英] Bootstrap DropDown menu doesn't work after first click
问题描述
我有我的下拉菜单在我的_Layout.cshtml并点击菜单项正常工作的第一次,例如带我去的 HTTP://本地主机:52098 /主页/ ViewTable /苏格兰 premiership。
I have my dropdown menu in my _Layout.cshtml and clicking on one of the menu items works fine the first time, for example takes me to http://localhost:52098/Home/ViewTable/Scottish Premiership.
如果我点击的URL再次,它试图带我去的http://本地主机:52098 /主页/ ViewTable /主页/ ViewTable /苏格兰 premiership
If I click on the URL again, it tries taking me to http://localhost:52098/Home/ViewTable/Home/ViewTable/Scottish Premiership
导航code:
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>
看起来像它采取从一个我已经上+的链接,因为那里是我真正想要的是一个绝对路径的href的相对路径?
Looks like it's taking a relative path from the one i'm already on + the href on the link, where as what I really want is an absolute path?
推荐答案
添加/你的URL的启动
Add '/' to the start of your URLs
像 /主页/ ViewMain /苏格兰锦标赛
和它始终是更好地使用
@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>
这篇关于引导下拉菜单没有第一次点击后工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!