我正在尝试使用下面的代码来提取URL中的最后一段,但它似乎不适用于下面显示的URL。有人可以检查下面的代码,然后告诉我这里缺少什么吗?谢谢
var segment_str = window.location.pathname;
var segment_array = segment_str.split( '/' );
var last_segment = segment_array[segment_array.length - 1];
alert(last_segment);
网址
http://localhost/projects/myproject/app/#/sales/invoices/224
我只需要提取224
有一个#
在URL,所以“224”是部分location
的hash
,不是pathname
。
var last_segment = window.location.hash.split('/').pop();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句