ViewChild 对我不起作用 - 升级到 beta7

ViewChild doesn’t work to me - upgrade to beta7

import {Page,NavController,NavParams,Platform,IonicApp} from 'ionic-angular';
import {ViewChild} from '@angular/core';

@Page({
    templateUrl: 'build/pages/tabspage/tabspage.html'
})

@ViewChild('myTabs') tabRef: Tabs

export class TabsPage {
     tab1;
     tab2;
     tab3;

     constructor(app:IonicApp, params:NavParams) {
        this.tab1 = Page1;
        this.tab2 = Page2;
        this.tab3 = Page3;

     }


     onPageDidEnter() {
         this.tabRef.select(1);
      }

}

我有这个代码。此代码位于打字稿文件中。我收到错误:错误 TS1146:需要声明。

因为上面说期待申报,我想你可能需要提前import 'Tabs' class。

import {Tabs} from '..~~tabs';

@ViewChild() 应该在您的 class 声明中。

export class TabsPage {
    @ViewChild('myTabs') tabRef: Tabs
    ...
}