我正在尝试将图标添加到以下简单的反应导航绘图仪:
export default createAppContainer(createDrawerNavigator({
Home: {
screen: HomeScreen,
icon: 'home'
},
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
},
Screen3: {
screen: Screen3
},
}));
抽屉很好,但图标不是。
确保您已导入本机矢量图标以在任何组件中使用图标。
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
},
}));
图标需要是诸如<Image>
或<View>
之类的组件,而不是字符串。