React Native:导航选项不起作用
ReactNative: navigationOptions not working
无法使用导航选项功能更改标题标题或标题样式。也改用 defaultNavigationOptions 但仍然无法正常工作。
const CategoriesScreen = props => {
const renderGridItem = itemData => {
return (
<TouchableOpacity
style={styles.gridItem}
onPress={() => {
props.navigation.navigate({ routeName: 'CategoryMeals' });
}}
>
<View>
<Text>{itemData.item.title}</Text>
</View>
</TouchableOpacity>
);
};
return (
<FlatList
keyExtractor={(item, index) => item.id}
data={CATEGORIES}
renderItem={renderGridItem}
numColumns={2}
/>
);
};
CategoriesScreen.navigationOptions = {
headerTitle: 'Meal Categories',
headerStyle: {
backgroundColor: Platform.OS === 'android' ? Colors.primaryColor : ''
},
headerTintColor: Platform.OS === 'android' ? 'white' : Colors.primaryColor
};
如有任何帮助,我们将不胜感激。谢谢
你错了,因为你应该使用标题而不是 headerTitle 就像
title: 'Meal Categories',
而不是
headerTitle: 'Meal Categories',
遇到同样的问题。就我而言,我只需要重新加载我的应用程序
无法使用导航选项功能更改标题标题或标题样式。也改用 defaultNavigationOptions 但仍然无法正常工作。
const CategoriesScreen = props => {
const renderGridItem = itemData => {
return (
<TouchableOpacity
style={styles.gridItem}
onPress={() => {
props.navigation.navigate({ routeName: 'CategoryMeals' });
}}
>
<View>
<Text>{itemData.item.title}</Text>
</View>
</TouchableOpacity>
);
};
return (
<FlatList
keyExtractor={(item, index) => item.id}
data={CATEGORIES}
renderItem={renderGridItem}
numColumns={2}
/>
);
};
CategoriesScreen.navigationOptions = {
headerTitle: 'Meal Categories',
headerStyle: {
backgroundColor: Platform.OS === 'android' ? Colors.primaryColor : ''
},
headerTintColor: Platform.OS === 'android' ? 'white' : Colors.primaryColor
};
如有任何帮助,我们将不胜感激。谢谢
你错了,因为你应该使用标题而不是 headerTitle 就像
title: 'Meal Categories',
而不是
headerTitle: 'Meal Categories',
遇到同样的问题。就我而言,我只需要重新加载我的应用程序