2016-04-25 71 views
0

我正在將名爲Swiper-Angular2的組件導入到IONIC 2項目中,但我收到一個奇怪的錯誤,說:IONIC2 - SyntaxError:docs/file.js:解析文件時意外的標記(13:22):docs/file.js

SyntaxError: docs/file.js: Unexpected token (13:22) while parsing file: docs/file.js

到目前爲止,我的代碼是:

page.js

import {Page} from 'ionic-angular'; 
import {Example1} from '../swiper/swiper'; 


@Page({ 
templateUrl: 'build/pages/home/home.html', 
directives: [Example1] 
}) 
export class HomePage {} 

page.html中

<ion-content> 
<example1><example1> 
</ion-content> 

swiper.js

import {Component, ViewChild, AfterViewInit} from 'angular2/core'; 
import {KSSwiperContainer, KSSwiperSlide} from 'angular2-swiper'; 

@Component({ 
selector: 'example1', 
pipes: [], 
providers: [], 
directives: [KSSwiperContainer, KSSwiperSlide], 
template: require('./swiper.html') 
}) 
//The error triggers here, exactly after "Example1" 
export class Example1 implements AfterViewInit { 

@ViewChild(KSSwiperContainer) swiperContainer: KSSwiperContainer; 

example1SwipeOptions: any; 

constructor() { 
this.example1SwipeOptions = { 
    slidesPerView: 4, 
    loop: false, 
    spaceBetween: 5 
}; 
} 

moveNext() { 
this.swiperContainer.swiper.slideNext(); 
} 

movePrev() { 
this.swiperContainer.swiper.slidePrev(); 
} 

ngAfterViewInit() { 
console.log(this.swiperContainer); 
} 

} 

Swiper.html

<div class="myslides"> 
<ks-swiper-container [options]="example1SwipeOptions"> 
<ks-swiper-slide *ngFor="#s of [1,2,3,4,5,6,7]"> 
<img src="http://api.randomuser.me/portraits/thumb/men/{{s}}.jpg"> 
</ks-swiper-slide> 
</ks-swiper-container> 
<button (click)="movePrev()">Prev</button> 
<button (click)="moveNext()">Next</button> 
</div> 

上什麼導致該問題的任何想法?

+0

你在你的Ionic2項目中使用ES6嗎? –

+0

這個文件的內容是什麼:'docs/file.js'?謝謝! –

+1

ES6已經存在,我可以在app.js中清楚地看到它。 file.js == swiper.js –

回答

相關問題