HarmonyOS 轮播swiper组件如何手动控制跳转到某个Index

HarmonyOS  轮播swiper组件如何手动控制跳转到某个Index。

HarmonyOS
2024-09-24 11:32:26
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

Swiper组件的index属性支持状态绑定,修改该状态变量即可实现跳转到指定index,demo:

@State currentIndex:number = 1  
…  
Swiper(this.swiperController) {  
  …  
}  
.index(this.currentIndex) //使用状态变量  
…  
Row() {  
  Button(‘to index 3’)  
  .onClick(() => {  
    this.currentIndex = 3 //状态变量修改值  
  })  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
分享
微博
QQ
微信
回复1
2024-09-24 15:53:57
相关问题
HarmonyOS 如何禁止Swipe向某个index滑动
497浏览 • 1回复 待解决
HarmonyOS 如何跳转到应用商店
676浏览 • 1回复 待解决
HarmonyOS如何跳转到发短信页面
1603浏览 • 1回复 待解决
HarmonyOS 如何跳转到应用设置页面?
1197浏览 • 1回复 待解决
如何跳转到WIFI列表页面?
1305浏览 • 1回复 待解决
如何实现Fraction跳转到AbilitySlice
10719浏览 • 3回复 已解决
如何实现跳转到系统设置
2777浏览 • 1回复 待解决
Swiper轮播图带放大缩小动效实践
2422浏览 • 1回复 待解决
HarmonyOS 如何跳转到系统位置开关页
737浏览 • 1回复 待解决