当涉及href时,scrollPositionRestoration失败-Angular 7

时间:2019-04-09 16:59:38

标签: angular router

我正在使用Option Explicit Sub Change_Cell_To_False() Dim result As String result = active_users("4/1/2019", "4/1/2019", "4/15/2019", "4/1/2019", " 4/20/2019", "4/20/2019", "4/21/2019", 0) If result = False Then ActiveSheet.Range("P3") = "False" End If End Sub Private Function active_users(ByVal cad_desde As Date, ByVal cad_fin As Date, ByVal last_log As Date, ByVal creacion As Date, ByVal per_desde As Date, ByVal per_fin As Date, ByVal download As Date, ByValbloq As Integer) As Boolean If bloq = 0 Or bloq = 128 Then If cad_fin < per_desde And last_log < per_desde Then active_users = False ElseIf cad_fin >= per_desde And cad_fin <= download And download <= per_fin And last_log < per_desde Then active_users = False Else active_users = True End If End If End Function 始终从其顶部显示我的组件,并且它确实有效。问题是,当我在同一个组件(scrollPositionRestoration())上使用不同的引用时,而不是调用href跳到另一个组件时。

代码

routerLink

路由器

<li class="nav-item">
  <a class="nav-link js-scroll-trigger text-warning" href="#ourteam">Our Team</a>
</li>
<li class="nav-item">
   <a class="nav-link js-scroll-trigger text-warning" routerLink="blog">Blog</a>
</li>

在这种情况下,它适用于@NgModule({ imports: [ RouterModule.forRoot(routes, { scrollPositionRestoration: "enabled" }) ], exports: [RouterModule] }) ,但不适用于routerLink。当我单击href时,我需要单击两次(我猜这是第一次在路由器上使用ourTeam滚动到组件顶部时引起的,并且第二次在同一组件上时,我不需要调用路由器,因此不必调用scrollPositionRestoration

0 个答案:

没有答案