1

我正在使用 Ionic 的幻灯片组件(基于 Swiper),效果很好。但是,我有一个特定的用例,我需要根据异步调用设置滑块的 spaceBetween 选项。

我尝试使用 .update() 方法,但没有任何效果。

public sliderOptions: Slider = {
    spaceBetween: 0
}

async ngOnInit() {
    await this.getDocuments();
}

async function getDocuments() {
    //this.sliderOptions.spaceBetween = -75; (HERE IT WORKS)

    let response = await this.service.getDocuments();

    this.sliderOptions.spaceBetween = -75; // DOESN'T WORK
    this.slides.update().then(() => console.log('SLIDER UPDATED'));
}

<ion-slides #slides [options]="sliderOptions">
....
</ion-slides>

我究竟做错了什么?

4

0 回答 0