react-native - 当我从反应原生的一个选项卡导航到另一个页面时,如何从顶部删除选项卡栏
问题描述
每个人我都面临 react-native 的问题,因为我是新手。
我从主页调用一个标签页,所以在标签页顶部有一个导航栏,在这个导航栏下方,一个标签栏显示两个标签。
到目前为止这很好,但问题从这里开始 在 tabPage 我有两个选项卡 -> tab1 和 tab2 从 tab1 我导航到页面 MainPage1 ,它在导航栏下方显示一个导航栏,在标签栏下方显示一个标签栏,另一个导航栏。如图所示。
我完全无法同时删除标题为“Stopages”的顶级导航栏和标签栏。
我正在使用 Tabview 来创建这个 tabbpage 并使用 stacknavigator 来导航到不同的页面。我被困在这里并且无法找到解决方案
注意->我尝试过使用
navigationOptions: {
tabBar: ({ state }) => ({
visible: false
})
但它什么也没做请帮忙
class TabPage extends React.Component{
state = {
index: 0,
routes: [
{ key: 'Stopagess', title: 'Stopages' },
{ key: 'MapStopagess', title: 'Maps' },
],
};
render() {
return (
<TabView
navigationState={this.state}
renderScene={SceneMap({
Stopagess: Stopages,
MapStopagess: MapStopages,
})
}
renderTabBar={props =>
<TabBar
{...props}
style = {{backgroundColor:'#3f51b5'}}
indicatorStyle={{ color: 'pink' }}
/>
}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
indicatorStyle={{ backgroundColor: 'pink' }}
/>
);
}
}
这是我的停课课
class Stopages extends Component {
render()
{
return (
<StopageDetail/>
)
}
}
const StopageDetail = createStackNavigator({
Stp:{
screen: Stpforsomeissue,
navigationOptions: () => ({
header:null,
tabBarVisible: false,
}),
},
NextDetailStopage:{
screen :StopageDetailOfStudents,
navigationOptions: ({ navigation, screenProps }) => ({
title: 'Stopages Detail',
// tabBarVisible: navigation.state.params=false,
headerStyle: { backgroundColor: '#ffd600'},
/>,
})
}
})
解决方案
您可以navigationOptions
在一个选项卡内createMaterialTopTabNavigator
按顺序播放哪些有 TopTabBar 或没有,例如:
export const Dashboard = createMaterialTopTabNavigator({
First: {
screen: FirstScreen, // This is my first Tab (a View)
navigationOptions: {
title: 'First'
}
},
Second: {
screen: SecondStack, // This is another Stack
navigationOptions: ({ navigation }) => ({
title: 'SecondStack',
tabBarVisible: navigation.state.index === 0, //Tab bar will be visible depending of the state (you can put another index)
animationEnabled: true
})
},
Third: {
screen: ThirdScreen, // This is my third Tab (a View)
navigationOptions: {
title: 'ThirdScreen',
}
}
});
推荐阅读
- android - Android textview 可水平滚动
- x86 - UEFI 引导加载程序中的 SPI 寄存器读写应用程序
- visual-studio - 使用 VS 2017 中的 cl.exe 编译 arm 或 arm64 程序时缺少 mspdbcore.dll
- swagger-ui - Swagger UI 的 requestInterceptor 中的 Promise
- react-native - 为什么使用 this.setState 会导致超过最大更新深度?
- javascript - Javascript 未显示所需的值
- mysql - 如何从别名中找到mysql中的总数(总和)?
- java - 使用BLE同步多个设备的时间
- sql - SQL批量复制:触发器没有被触发
- reactjs - 浅层和装载包装器中的酶模拟有什么区别?