在 Ionic 4 中导入幻灯片时显示错误

Error is showing when importing the Slides in Ionic 4

我正在我的 Ionic 4 应用程序中工作,我已经在我的应用程序中导入了幻灯片,但它显示错误。

这是我的intro.page.ts:

import { Slides } from '@ionic/angular';
@Component({
  selector: 'app-intro',
  templateUrl: './intro.page.html',
  styleUrls: ['./intro.page.scss'],
})
export class IntroPage implements OnInit {
  @ViewChild('slides') slides: Slides;
  constructor(private storage: Storage, private router: Router) { }

  ngOnInit() {
  }

  next() {
    this.slides.slideNext();
  }
}

错误:

Module '"../../../../../Users/challengesnew/node_modules/@ionic/angular/dist/core"' has no exported member 'Slides'.

非常感谢任何帮助。

根据 GitHub issue and the mentioned changelog, 如果要导入,所有离子组件都以 Ion 为前缀。

将您的导入更改为:

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

 @ViewChild('slides') slides: IonSlides;

现在,使用 Angular 8,导入保持不变:

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

@ViewChild 装饰器中, static 属性 在 options参数,如下:

@ViewChild('slides', {static: true}) slides: IonSlides;