0
我跟着這個鏈接來創建一個滑塊。 http://ionicframework.com/docs/v2/api/components/slides/Slides/Ionic2 @ViewChild意外令牌
但是,當我嘗試使用ViewChild訪問本地模板變量時,它給了我一個錯誤。
Unexpected token (10:44) while parsing file: /Users/shawn/Desktop/Ionic/abcdefg/app/pages/dashboard/dashboard.js
這是我的源代碼
dashboard.html
<ion-content>
\t <div class="black-mask">
\t \t <div class="calendar">
\t \t \t <ion-slides #calendarSlider (didChange)="onSlideChanged()" [options]="slideOptions">
\t \t \t \t <ion-slide>
\t \t \t \t \t <div class="calendar-cell" *ngFor="#cal of previousCalendar; #i = index" [ngClass]="{selected: cal.selected}" (click)="toggle('previous', i)">
\t \t \t \t \t \t <span class="calendar-day">{{ cal.dayOfWeek }}</span>
\t \t \t \t \t \t <span class="calendar-day-number">{{ cal.day }}</span>
\t \t \t \t \t </div>
\t \t \t \t </ion-slide>
\t \t \t \t <ion-slide>
\t \t \t \t \t <div class="calendar-cell" *ngFor="#cal of currentCalendar; #i = index" [ngClass]="{selected: cal.selected}" (click)="toggle('current', i)">
\t \t \t \t \t \t <span class="calendar-day">{{ cal.dayOfWeek }}</span>
\t \t \t \t \t \t <span class="calendar-day-number">{{ cal.day }}</span>
\t \t \t \t \t </div>
\t \t \t \t </ion-slide>
\t \t \t \t <ion-slide>
\t \t \t \t \t <div class="calendar-cell" *ngFor="#cal of nextCalendar; #i = index" [ngClass]="{selected: cal.selected}" (click)="toggle('next', i)">
\t \t \t \t \t \t <span class="calendar-day">{{ cal.dayOfWeek }}</span>
\t \t \t \t \t \t <span class="calendar-day-number">{{ cal.day }}</span>
\t \t \t \t \t </div>
\t \t \t \t </ion-slide>
\t \t \t </ion-slides>
\t \t </div>
\t </div>
</ion-content>
dashboard.js
import {Page, NavController, Slides} from 'ionic-angular';
import {ViewChild} from 'angular2/core';
import {LoginPage} from '../login/login';
import moment from 'moment';
@Page({
\t templateUrl: 'build/pages/dashboard/dashboard.html',
\t queries: {
\t \t calendarSlider: new ViewChild('calendarSlider')
\t }
})
export class DashboardPage {
\t @ViewChild('calendarSlider') calendarSlider: Slides;
\t static get parameters() {
\t \t return [[NavController]];
\t }
\t constructor(nav) {
\t \t this.nav = nav;
\t \t console.log(this.calendarSlider);
\t \t // Calendar Slider Options.
\t \t // 0: Previous
\t \t // 1: Current
\t \t // 2: Next
\t \t this.slideOptions = {
\t \t \t initialSlide: 1,
\t \t \t loop: true
\t \t };
(.......)
}
嗨蒂埃裏,它沒有工作後,將查詢添加到頁面。 –
我仍然收到意想不到的令牌 –
它在我身邊。在哪條線上發生此錯誤? –