是否有一个内置的方式来获得无任何查询参数当前的URL? [英] Is there a built-in way to get the current URL without any query parameters?
本文介绍了是否有一个内置的方式来获得无任何查询参数当前的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我的网址 http://www.something.com/foo/bar/index.html?color=yellow&animal=rat
,它好像
-
$ location.path()
将返回富/酒吧/ index.html的
-
$ location.absUrl()
将返回http://www.something.com/foo/bar/index.html?color=黄色和放大器;动物=鼠
-
$ location.url()
将返回富/酒吧/ index.html的颜色=黄色和放大器;动物大鼠=
$location.path()
will returnfoo/bar/index.html
$location.absUrl()
will returnhttp://www.something.com/foo/bar/index.html?color=yellow&animal=rat
$location.url()
will returnfoo/bar/index.html?color=yellow&animal=rat
有没有这将返回任何功能 http://www.something.com/foo/bar/index.html
?
Is there any function which will return http://www.something.com/foo/bar/index.html
?
还是我必须要构建自己像协议型,主机,端口等功能(或剥离查询参数过我自己)?
Or do I have to construct that myself with functions like protcol, host, port, etc. (or strip the query params off myself)?
推荐答案
据我所知,你必须自己建立它。这并不是说你问如何构建它,但对于那些谁是纳闷:
As far as I'm aware you have to construct it yourself. Not that you were asking how to construct it, but for those who are wondering:
var url = $location.absUrl().split('?')[0]
这篇关于是否有一个内置的方式来获得无任何查询参数当前的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文