【发布时间】:2021-11-27 23:46:28
【问题描述】:
我第一次使用 Ionic 和 React。使用 swiper 时,每个视图属性的幻灯片数量没有得到尊重,只显示了 1 张幻灯片。我做错了什么?
我正在使用以下导入:
`import { Swiper, SwiperSlide } from 'swiper/react';
导入'swiper/swiper-bundle.css'`
<IonGrid>
<IonRow>
<IonCol size="3">
<IonSelect
onIonChange={((e) => {
setForm({album: form.album, month: form.month, year: e.detail.value});
})}
value={String(form.year)}>
{[...Array(10)].map((num, i) =>
<IonSelectOption
key={`year_${form.year - i}`}>
{form.year - i}
</IonSelectOption>
)}
</IonSelect>
</IonCol>
<IonCol size="9">
<Swiper
slidesPerView={6}
onSwiper={(swiper) => console.log(swiper)}
onTap={(context) => onMonthTap(context)}
initialSlide={ form.month }>
{["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map((mon, idx) => {
return (
<>
<SwiperSlide key={`month_${idx}`}>
<IonLabel>{form.month === idx ? <b>{mon}</b> : mon}</IonLabel>
</SwiperSlide>
</>
)
})}
</Swiper>
</IonCol>
</IonRow>
</IonGrid>
【问题讨论】:
标签: reactjs ionic-framework swiper ionic5 swiperjs