index变化的时候调用页面的方法,应该怎么实现?比如调用ServicePage里的方法
TabContent(){
HomePage()
}
.tabBar(this.tabBuilder(0,'首页',$r('app.media.fourth_hp_one_selected'),$r('app.media.fourth_hp_one_unselected')))
TabContent(){
InformationPage()
}
.tabBar(this.tabBuilder(1,'资讯',$r('app.media.fourth_hp_two_selected'),$r('app.media.fourth_hp_two_unselected')))
TabContent(){
ServicePage()
}
.tabBar(this.tabBuilder(2,'服务',$r('app.media.fourth_hp_three_selected'),$r('app.media.fourth_hp_three_unselected')))
TabContent(){
MinePage()
}
.tabBar(this.tabBuilder(3,'我的',$r('app.media.fourth_hp_four_selected'),$r('app.media.fourth_hp_four_unselected')))
}
.barMode(BarMode.Fixed)
.onChange((index) => {
this.currentIndex = index
//index变化的时候调用页面的方法,应该怎么实现?比如调用ServicePage里的方法。
ServicePage()
})
可以参考如下demo: