导入幻灯片不适用于 Ionic 4?

Import Slides doesn't working on Ionic 4?

所以,我正在尝试将 Ionic Slides 导入我的项目,但我收到此消息:"...没有导出成员 'Slides'"

我是这样导入的:

import { Slides } from '@ionic/angular';

然后剩下的代码:

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  @ViewChild("audio") audio;
  @ViewChild(Slides) slides: Slides;

  constructor(public navCtrl: NavController) {

  }

  ngAfterViewInit() {

    let self = this;

    this.audio.nativeElement.oncanplaythrough = () => {

      this.audio.nativeElement.onplay = function () {

        self.slides.autoplay = 1000;
        self.slides.startAutoplay();

      };

      this.audio.nativeElement.onpause = function () {

        self.slides.autoplay = undefined;
        self.slides.stopAutoplay();

      };

    };
  }

}

This answer on a GitHub issue 说 Ionic 4 的文档中有一个重命名。将 Slides 重命名为 IonSlides 应该可以解决问题。

Please take a look at the breaking changes for beta.18: https://github.com/ionic-team/ionic/blob/master/CHANGELOG.md#angular-prefixed-ion--components

Everything is prefixed with Ion, so instead of Slides it's IonSlides:

import {IonSlides} from '@ionic/angular';

...

@ViewChild(IonSlides) slides: IonSlides;
import {IonSlides} from '@ionic/angular';

export class HomePage {
@ViewChild(IonSlides) slides: IonSlides;

这个解决了我在 ionic 4 中的问题

import { IonSlides } from '@ionic/angular';
export class IntroScreenPage implements OnInit {
@ViewChild('slides', { read: true, static: false }) ionSlides: IonSlides;

我传递了第二个参数{ read: true, static: false }