
回复
有需求让Swiper组件跳到指定页
官方文档给到的代码是这样的
首先定义一个 Swiper controller
private controller: SwiperController = new SwiperController();
该controller在swiper组件作为入参数带入
this.controller.showIndex(index) 这个方法显示没作用
Swiper(this.controller){
//省略业务代码
...
Button(()=>{
})
.onClick(()=>{
this.controller.showIndex(index)
})
}
需要使用这个方法才能跳到正确的页面
.index(this.currentIndex)
Swiper(this.controller){
Button(()=>{
//....
}).onClick(()=>{
this.currentIndex = index
)
}.index(this.currentIndex)