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

use*_*127 0 ionic-framework ionic2 angular

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

}
Run Code Online (Sandbox Code Playgroud)

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

Abd*_*yer 8

@ViewChild()应该是你的类的声明中。

export class TabsPage {
    @ViewChild('myTabs') tabRef: Tabs
    ...
}
Run Code Online (Sandbox Code Playgroud)