我使用Error in array(NA, c(J, K)) : 'dims' cannot be of length 0
设置了以下路由器:
React-Navigation
我在堆栈导航器中设置了headerTitle,因此它按以下方式工作:如果用户在const MainView = createDrawerNavigator(
{
DrawerMain: {
screen: StackNavScreens,
},
},
{
drawerPosition: 'left',
contentComponent: Settings,
},
);
const StackNavScreens = createStackNavigator(
{
Main: {
screen: TabNav,
},
Screen1: {
screen: Screen1,
navigationOptions: {
headerTitle: 'Screen1 Title',
},
},
Screen2: {
screen: Screen2,
},
},
{
navigationOptions: () => ({
headerTitle: <Image source="Logo" />,
})
}}
const TabNav = createMaterialTopTabNavigator(
{
Tab1: {
screen: Tab1Screen,
},
Tab2: {
screen: Tab2Screen,
},
Tab3: {
screen: Tab3Screen,
},
},{});
,导航标题将显示为Screen1
。如果他去Screen1 Title
,他会看到徽标(Screen2
)。但是,我很难截取<Image source="Logo"/>
,Tab1
和Tab2
的标题标题。我已尝试在Tab3
中为每个标签传递headerTitle
- 但它没有任何效果。现在,所有标签都显示navigationOptions
的默认headerTitle
- 徽标。
有关如何在描述的方案中为标签设置标题标题的任何建议?
答案 0 :(得分:0)
我遇到了同样的问题,在阅读了Github上的这个问题https://github.com/react-navigation/react-navigation/issues/741之后,我找到了解决方法。您接近了,只需在navigationOptions
的{{1}}对象内添加Main
StackNavScreen
我希望你很幸运,发现这个答案对你有帮助,加油!
答案 1 :(得分:0)
我创建了一个createStackNavigator,包装了createMaterialTopTabar和此createStackNavigator的配置标头。效果很好。
const WatchTopTabNavigator = createMaterialTopTabNavigator({
VideoScreen: {
screen: VideoStack,
navigationOptions: {
tabBarLabel: 'Video',
tabBarIcon: ({
tintColor
}) => ( <
Image source = {
require('../assets/images/video.png')
} //eslint-disable-line
style = {
{
tintColor,
width: 24,
height: 24
}
}
/>
)
}
},
PhotoScreen: {
screen: Photo,
navigationOptions: {
tabBarLabel: 'Ảnh',
tabBarIcon: ({
tintColor
}) => ( <
Image source = {
require('../assets/images/video.png')
} //eslint-disable-line
style = {
{
tintColor,
width: 24,
height: 24
}
}
/>
)
}
},
}, {
tabBarOptions: {
tabStyle: {
backgroundColor: 'white',
},
style: {
},
labelStyle: {
fontWeight: 'bold',
color: 'red'
}
}
});
const WatchRoute = createStackNavigator({
watchTopTabNavigator: WatchTopTabNavigator
}, {
navigationOptions: {
headerTitle: < Header / >
}
});