角历史路线和碎片
我的Angular应用程序使用“历史路由路径”
localhost/blog/acrate/:ID
在OPEN Localhost/blog/actity/123456
上此路由时渲染
降价内容
- [one](#one)
- [two](#two)
# one
some thing
# two
some thing
渲染html
<a herf="#one">one</a>
<a herf="#two">two</a>
<h1 id="one">one</h1>
<p>some thing</p>
<h1 id="two">one</h1>
<p>some thing</p>
,但单击标签重定向到root路径,
单击标签时如何滚动到片段
--------------------------------------------------------------------------------
在
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在routermotule.forroot()中启用aNchorsCrolling(如下): -
并使用片段属性分配如上上面的片段而不是HREF。
您可以在此处阅读有关它的信息: -
htttps:htttps:// mided。 com/dev-genius/Advanced-router-configuration-in-angular-d22c6dc420be
or: -
You need to enable anchorScrolling in RouterModule.forRoot() like below :-
And use fragment attribute to assign the fragment like above instead of href.
You can read about it here :-
https://medium.com/dev-genius/advanced-router-configuration-in-angular-d22c6dc420be
Or :-
https://angular.io/api/router/ExtraOptions