我正在使用$anchorScroll
滚动到页面顶部,其中 html 元素具有 ID #brand
。
<body>
<header id="brand">
<!--Content-->
</header>
</body>
AngularJS 代码:
$location.hash("brand");
$anchorScroll();
但是,$anchorScroll
运行后,页面url变为http://localhost:8080/##brand
,即##brand
code> 附加到原始 url 后。使用$anchorScroll
时如何保留原始url?提前致谢!
最佳答案
以显式形式使用 $anchorScroll 似乎有效,至少在 html5mode 时如此。已开启。
(do not call $location.hash())
$anchorScroll('brand');
关于angularjs - 防止$anchorScroll修改url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38079284/