路由回BottomNavigation组件后,NativeScript ListView项消失

在我的NativeScript应用中,有一个BottomNavigation标签:

asadmin>flush-connection-pool __db

在这些子选项卡之一中,有一个项目的RadListView:

const routes: Routes = [
    {
        path: 'tabs',component: TabsComponent,children: [
            {
                path: 'feed',loadChildren: '~/app/pages/feed/feed.module#Feedmodule',component: NSEmptyOutletComponent,outlet: 'feedTab'
            },{
                path: 'notification',loadChildren: '~/app/pages/notification/notification.module#Notificationmodule',outlet: 'notificationTab'
            },{
                path: 'create',loadChildren: '~/app/pages/create/create.module#CreateModule',outlet: 'createtab'
            },{
                path: 'profile',loadChildren: '~/app/pages/profile/profile.module#ProfileModule',outlet: 'profiletab'
            }
        ]
    }
];

导航到该选项卡时,列表将按预期填充,但是如果您导航到另一个选项卡的子组件,然后直接回到BottomNavigation:

子组件:

<actionBar id="profile-action-bar" title="Notifications"></actionBar>
<GridLayout>
  <RadListView separatorColor="transparent" class="notification-list" [items]="notificationList"
    (loadmoreDataRequested)="onLoadmoreItemsRequested($event)" loadOnDemandmode="Auto"
    (itemTap)="onNotificationTap($event)">
    <!-- (itemTap)="ongoalTap($event)" -->

    <ng-template let-item="item" let-i="index">
      <ns-notification-item [item]=item [position]=i></ns-notification-item>
    </ng-template>

  </RadListView>
</GridLayout>

ListView中先前加载的所有项目均已消失...但是之前未加载的项目将开始填充列表

zhujun1918 回答:路由回BottomNavigation组件后,NativeScript ListView项消失

“路由器出口”和“页面路由器出口”有很大的不同。在网络上,当您导航时,当前路线上的所有组件都将被销毁,并呈现导航路线的新组件。

使用移动应用程序时,您可以保留导航堆栈,然后从右上角返回上一页。为此,您可以使用Page Router Outlet,而要处理Page Router Outlet,则需要RouterExtensions

要返回历史记录的上一页,应在back()上调用RouterExtensions方法。

Updated Playground

本文链接:https://www.f2er.com/3000120.html

大家都在问