【问题标题】:ion slider not working in ModalController ionic 4离子滑块在 ModalController ionic 4 中不起作用
【发布时间】:2020-09-21 16:44:40
【问题描述】:

版本: 科尔多瓦:cordova-lib@8.1.1 离子:6.10.1

错误:this.slider.update is not a function

在.ts中

import { ModalController, IonSlides } from "@ionic/angular";

 trainingSliderOpts = {
speed: 400,
initialSlide: 0,
preloadImages: true,
allowTouchMove: false,
 };
result: any;
@ViewChild("trainingSlider", { static: true }) slider: IonSlides;

  ionViewDidEnter() {
this.slider.update();
}

【问题讨论】:

    标签: ionic-framework ionic4


    【解决方案1】:

    尝试像这样在末尾添加一个 .then 函数:

    this.ionSlides.update().then(() =>
            console.log('updated'))
        }
    

    如果不起作用,请在您的班级上尝试以下操作:

     @ViewChild('slider', {read: ElementRef})slider: ElementRef;
    

    然后这样称呼它:

    this.slider.nativeElement.update();
    

    【讨论】:

    • 这不起作用 r: this.slider.update 不是一个函数
    • 'ngForOf' 因为它不是 'ion-slide' 的已知属性。但是为 ngForOF 解决这个问题有什么想法吗?
    • 我不确定你的意思,你想使用 *ngFor 吗?
    • 是的,在使用 nativeElelment 进行更改后,ngFor 不起作用
    猜你喜欢
    • 2015-06-18
    • 2019-07-18
    • 2020-04-21
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多