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

耗尽温柔 提交于 2019-12-25 09:48:43

问题


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

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)

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();
        }

  }

来源:https://stackoverflow.com/questions/46821839/ionic3-didnt-set-nav-root-invalid-views-to-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!