ionic3 - Didn't set nav root: invalid views to

2019-08-24 16:00发布

When I click a button this warning coming out which I running it in my web browser.(ionic serve -l) enter image description here

I have <ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav> in my app.html file, is it problem?

UPDATE:

button image (button in slide menu - feedback button) enter image description here

app.html

<ion-list>
      <ion-list-header>导航栏</ion-list-header>
      <button menuClose ion-item *ngFor="let p of loggedInPages" (click)="openPage(p)">
      <ion-icon item-start [name]="p.icon" [color]="isActive(p)"></ion-icon>
        {{p.title}}
      </button>
    </ion-list>

app.components.ts

  appPages: PageInterface[] = [
    { title: '新闻', name: 'TabsPage', component: TabsPage, index: 0, icon: 'ios-globe-outline' },
    { title: 'SOS', name: 'TabsPage', component: TabsPage, index: 1, icon: 'call' },
    { title: '服务', name: 'TabsPage', component: TabsPage, index: 2, icon: 'people' },
    { title: '反馈', name: 'FeedbackPage', component: FeedbackPage, icon: 'information-circle' },
    // { title: '机场志愿者入口', name: 'TabsPage', component: TabsPage, index: 0, icon: 'minan-sos' }
  ];
  loggedInPages: PageInterface[] = [
    { title: '新闻', name: 'TabsPage', component: TabsPage, index: 0, icon: 'ios-globe-outline' },
    { title: 'SOS', name: 'TabsPage', component: TabsPage, index: 1, icon: 'call' },
    { title: '服务', name: 'TabsPage', component: TabsPage, index: 2, icon: 'people' },
    { title: '反馈', name: 'FeedbackPage', component: FeedbackPage, icon: 'information-circle' },
    { title: '注销', name: 'TabsPage', component: TabsPage, icon: 'log-out', logsOut: true }
  ];

openPage(page: PageInterface) {
    let params = {};
        if (page.index) {
          params = { tabIndex: page.index };
        }

        if (this.nav.getActiveChildNavs().length && page.index != undefined) {
          this.nav.getActiveChildNavs()[0].select(page.index);
        } else {
          // Set the root of the nav with params if it's a tab index
          this.nav.setRoot(this.nav.setRoot(page.component, params), params).catch((err: any) => {
            console.log(`Didn't set nav root: ${err}`);
          });
        }

        if (page.logsOut === true) {
          // Give the menu time to close before changing to logged out
          this.userData.logout();
        }

  }

0条回答
登录 后发表回答