【问题标题】:Error is showing when importing the Slides in Ionic 4在 Ionic 4 中导入幻灯片时显示错误
【发布时间】:2019-04-04 09:33:22
【问题描述】:

我正在使用 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();
  }
}

错误:

模块 '"../../../../../Users/challengesnew/node_modules/@ionic/angular/dist/core"' 没有导出的成员“幻灯片”。

非常感谢任何帮助。

【问题讨论】:

    标签: angular ionic-framework ionic4


    【解决方案1】:

    根据 GitHub issue 和提到的changelog, 如果要导入,所有离子组件都以Ion 为前缀。

    将您的导入更改为:

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

     @ViewChild('slides') slides: IonSlides;
    

    【讨论】:

      【解决方案2】:

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

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

      @ViewChild 装饰器中,options 参数中需要 static 属性,如下所示:

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

      【讨论】:

        猜你喜欢
        • 2019-08-25
        • 2019-09-20
        • 2010-11-06
        • 2021-11-05
        • 1970-01-01
        • 2021-05-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多