React Navigation DrwaerNavigator 中未显示的图标
Icons not shown in React Navigation DrwaerNavigator
我正在尝试将图标添加到下面的简单 React Navigation DrawerNavigator:
export default createAppContainer(createDrawerNavigator({
Home: {
screen: HomeScreen,
icon: 'home'
},
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
},
Screen3: {
screen: Screen3
},
}));
抽屉显示正常,但图标不正常。
图标必须是 <Image>
或 <View>
之类的组件,而不是字符串。
确保您已导入 React Native 矢量图标以在您的任何组件中使用图标。
import Ionicons from 'react-native-vector-icons/Ionicons';
export default createAppContainer(createDrawerNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
drawerIcon: () => <Ionicons name="ios-home" size={30} style={{ width: 24 }}
color="#000" />
}
},
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
},
Screen3: {
screen: Screen3
},
}));
我正在尝试将图标添加到下面的简单 React Navigation DrawerNavigator:
export default createAppContainer(createDrawerNavigator({
Home: {
screen: HomeScreen,
icon: 'home'
},
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
},
Screen3: {
screen: Screen3
},
}));
抽屉显示正常,但图标不正常。
图标必须是 <Image>
或 <View>
之类的组件,而不是字符串。
确保您已导入 React Native 矢量图标以在您的任何组件中使用图标。
import Ionicons from 'react-native-vector-icons/Ionicons';
export default createAppContainer(createDrawerNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
drawerIcon: () => <Ionicons name="ios-home" size={30} style={{ width: 24 }}
color="#000" />
}
},
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
},
Screen3: {
screen: Screen3
},
}));