向后导航时,Nativescript queryParamsMap无法正常工作

问题描述

实际上,我处于有两个屏幕的情况。一个是listComponent,另一个是DetailComponent。

在ListComponent.ts上

this.activatedRoute.queryParamMap.subscribe((params) => {
        console.log('param:' + params.get('updatedIndex'));
    })

当我点击列表中的任何项目时,我导航到ListDetails屏幕,并且在那里我对项目进行了一些更改。我希望每当我返回时,这些更改都能反映在ListComponent上。所以我在detailComponent中所做的是

this.routerExtension.navigate([],{
        relativeTo: this.activatedRoute,queryParams: {
            updatedIndex: this.listIndex
        },queryParamsHandling: 'merge'
    })

据我了解,这将更新我的路线中的queryparams。每当我返回listcomponent屏幕时,可观察到的queryParamMap都会触发。但是,当我第一次在ListComponent上导航时,我的queryParamMap仅触发一次。

下面是我的路线。

const routes: Routes = [
{ path: "list-details",component: ListDetailsComponent },{ path: "",component: MyListComponent },];

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)