Ich importiere eine Komponente namens Swiper-Angular2 in mein IONIC 2-Projekt, aber ich erhalte einen seltsamen Fehler, der sagt: mein CodeIONIC2 - SyntaxError: docs/file.js: Unerwartetes Token (13:22) beim Analysieren von Datei: docs/file.js
SyntaxError: docs/file.js: Unexpected token (13:22) while parsing file: docs/file.js
Bisher ist:
page.js
import {Page} from 'ionic-angular';
import {Example1} from '../swiper/swiper';
@Page({
templateUrl: 'build/pages/home/home.html',
directives: [Example1]
})
export class HomePage {}
seite.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>
Irgendwelche Ideen, was das Problem verursacht?
Verwenden Sie ES6 in Ihrem Ionic2-Projekt? –
Was ist der Inhalt dieser Datei: 'docs/file.js'? Vielen Dank! –
ES6 ist schon da, ich kann es deutlich in app.js sehen. file.js == swiper.js –