返回 JQuery 中 MVC 最终当前路径?
现在我正在使用...
window.location.pathname != "/x_Controller/x_View"
有什么方法可以只获取“x_View”吗?谢谢。
Right now I'm using...
window.location.pathname != "/x_Controller/x_View"
Is there any way to get just the "x_View"? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需执行
window.location.pathname
EDIT
的子字符串,正如银河建议的那样,如果它末尾有任何路由值,则不会为您提供操作名称
actionName/12
。您真正想要使用的是,这将为您提供操作的实际名称,而不仅仅是最后一个“/”之后的内容
You can just do a substring of the
window.location.pathname
EDIT
As Galactic suggested this won't get you the action name if it has any route values on the end like
actionName/12
. What you really want to use isThat will get you the actual name of the Action instead of just the stuff after the last '/'