我需要检测活动索引并将其存储。我在componentDidMount中声明了swiper,所以它只运行一次。索引变化时如何观看
private DOMSideSwiper = createRef<HTMLDivElement>()
public componentDidMount() {
const sideSwiper = new Swiper(this.DOMSideSwiper.current, {
initialSlide: this.props.store.BuildingData.idx,
slidesPerView: "auto",
direction: "vertical",
mousewheel: true,
navigation: {
nextEl: ".side-swiper-button-prev",
prevEl: ".side-swiper-button-next",
},
})
console.log(sideSwiper.activeIndex) // will display 0
}