[英]How to get bottomTab press action with wix react-native-navigation?
I have set up navigation with Bottom tabs in react-native-navigation, this is working fine我已经在 react-native-navigation 中设置了带有底部选项卡的导航,这工作正常
bottomTabs: {
id: 'BOTTOM_TABS_LAYOUT',
children: [
{
stack: {
id: 'HOME_TAB',
children: [
{
component: {
id: 'HOME_SCREEN'
name: 'HomeScreen'
}
}
],
options: {
bottomTab: {
icon: require('./home.png')
}
}
}
},
{
stack: {
id: 'PROFILE_TAB',
children: [
{
component: {
id: 'PROFILE_SCREEN',
name: 'ProfileScreen'
}
}
],
options: {
bottomTab: {
icon: require('./profile.png')
}
}
}
}
]
}
But I want to add some other code when I switch from a tab to another, how could this be done?但是当我从一个选项卡切换到另一个选项卡时,我想添加一些其他代码,这怎么做?
You can listen to tab selection events by registering a Navigation events listener.您可以通过注册导航事件侦听器来侦听选项卡选择事件。 The
tabSelected
event is emitted when the selected tab has changed. tabSelected
事件在所选选项卡发生更改时发出。
Navigation.events().registerBottomTabSelectedListener((selectedTabIndex, unselectedTabIndex) => {
});
If you'd like to handle the tab selection yourself, set the selectTabOnPress: false
option on the bottomTab
you'd like to handle selection for, and register a tabPressed
listener to handle the tab press event.如果您想自己处理选项卡选择,请在要处理选择的底部选项卡上设置
bottomTab
selectTabOnPress: false
选项,并注册一个tabPressed
侦听器来处理选项卡按下事件。 This event is emitted when a tab is pressed by the user.当用户按下选项卡时会发出此事件。
options: {
bottomTab: {
icon: require('./home.png'),
selectTabOnPress: false
}
}
Navigation.events().registerBottomPressedListener((tabIndex) => {
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.