简体   繁体   English

ViewChild未在IONIC中定义

[英]ViewChild is not define in IONIC

This is my app.components.ts file. 这是我的app.components.ts文件。 I am facing error for the viewchild. 我的Viewchild遇到错误。 Using Ionic 4.0.5. 使用Ionic 4.0.5。 I want to want navbar in my apps that contains a 'Menu'. 我想在我的应用程序中包含“菜单”的导航栏。

   import { Component } from '@angular/core';
    import { Platform } from 'ionic-angular';
    import { StatusBar } from '@ionic-native/status-bar';
    import { SplashScreen } from '@ionic-native/splash-screen';
    import { NavController } from 'ionic-angular';
    import { Menu } from '../pages/menu/menu';
    @Component({
      templateUrl: 'app.html'
    })
    export class MyApp {
      @ViewChild(Nav) nav: NavController;


      rootPage:any = Menu;

      constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
        this.initializeApp();
      }


      initializeApp() {

      this.platform.ready().then (() => {

        this.statusBar.styleDefault();
        this.splashScreen.hide();
      });
      }
    }

import ViewChild in ts file 在ts文件中导入ViewChild

import { Component,ViewChild } from '@angular/core';
@ViewChild(Nav) nav: NavController;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM