如何让所有的堆叠屏幕只有一个样式,因为它们都有一个相同的样式.如你所见.具有HeaderStyle、HeaderTitleStyle、HeaderLeft、HeaderTitleAlign的选项props 具有相同的值.
这是我的App.js文件
const MainNavigator = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="MainScreen">
<Stack.Screen
name="MagicScreen"
component={MagicScreen}
options={{
title: 'Magic',
headerStyle: {
backgroundColor: '#0074C4',
},
headerTitleStyle: {
color: 'white',
fontSize: 24
},
headerLeft: null,
headerTitleAlign: 'center',
}}
/>
<Stack.Screen
name="FightingStyleScreen"
component={FightingStyleScreen}
options={{
title: 'Fighting Style',
headerStyle: {
backgroundColor: '#0074C4',
},
headerTitleStyle: {
color: 'white',
fontSize: 24
},
headerLeft: null,
headerTitleAlign: 'center',
}}
/>
<Stack.Screen
name="WeaponScreen"
component={WeaponScreen}
options={{
title: 'Weapons',
headerStyle: {
backgroundColor: '#0074C4',
},
headerTitleStyle: {
color: 'white',
fontSize: 24
},
headerLeft: null,
headerTitleAlign: 'center',
}}
/>
</Stack.Navigator>
</NavigationContainer>
)
};
我试图在Google上找到示例代码.但还是找不到这个例子:")