React native 正确的RNN V2结构是什么样子的?
我一直在尝试制作一个合适的RNN V2树,但它对我来说毫无意义。。。举个例子:React native 正确的RNN V2结构是什么样子的?,react-native,react-native-navigation,react-native-navigation-v2,React Native,React Native Navigation,React Native Navigation V2,我一直在尝试制作一个合适的RNN V2树,但它对我来说毫无意义。。。举个例子: root: { bottomTabs: { children: [ { component: { name: 'Main', options: {
root: {
bottomTabs: {
children: [
{
component: {
name: 'Main',
options: {
bottomTab: {
text: 'Main',
},
},
},
},
{
component: {
name: 'Secondary',
options: {
bottomTab: {
text: 'Secondary',
},
},
},
},
],
},
},
}
假设我想告诉导航器在活动的底部选项卡上使用红色。如果我想实现这一点,那么我需要向每个组件添加selectedTextColor
与底部选项卡可见、隐藏等相同。。。
如何在父级中设置一次,并让子级继承这些选项?每个BottomTab的选项都是自底向上解析的,因此BottomTab选项只能定义一次 让我们看一个稍微复杂一些的布局,取自游乐场应用程序:
Navigation.setRoot({
root: {
bottomTabs: {
id: 'BottomTabs',
children: [
{
stack: {
id: 'TAB1_ID',
children: [
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 1',
myFunction: () => 'Hello from a function!'
},
options: {
topBar: {
visible: true,
animate: false,
title: {
text: 'React Native Navigation!'
}
},
}
}
}
],
options: {
topBar: {
visible: false
},
bottomTab: {
text: 'Tab 1',
icon: require('../images/one.png'),
selectedIcon: require('../images/one.png'),
testID: testIDs.FIRST_TAB_BAR_BUTTON
}
}
}
},
{
stack: {
children: [
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 2'
}
}
}
],
options: {
bottomTab: {
text: 'Tab 2',
icon: require('../images/two.png'),
testID: testIDs.SECOND_TAB_BAR_BUTTON
}
}
}
},
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 3',
myFunction: () => 'Hello from a function!'
},
options: {
topBar: {
visible: true,
animate: false
},
bottomTab: {
text: 'Tab 3',
icon: require('../images/one.png'),
selectedIcon: require('../images/one.png')
}
}
}
}
],
options: {
bottomTabs: {
titleDisplayMode: 'alwaysShow',
testID: testIDs.BOTTOM_TABS_ELEMENT
}
}
}
}
});
如您所见,BottomTab选项可以在堆栈选项或组件的选项中声明。
这是因为从每个选项卡的当前布局树中解析选项。
重要的是要记住,选项是自下而上解决的,这意味着从根开始声明的更深的选项优先于更靠近根的更高的选项
让我们仔细看看BottomTab的第一个子项。在本例中,它是一个声明bottomTab选项的堆栈。推送到该堆栈的任何子项都可以覆盖堆栈的底部选项卡选项,因为它在布局树中较深-堆栈的选项可以被视为默认选项。每个底部选项卡的选项都是自底向上解析的,因此底部选项卡选项只能定义一次 让我们看一个稍微复杂一些的布局,取自游乐场应用程序:
Navigation.setRoot({
root: {
bottomTabs: {
id: 'BottomTabs',
children: [
{
stack: {
id: 'TAB1_ID',
children: [
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 1',
myFunction: () => 'Hello from a function!'
},
options: {
topBar: {
visible: true,
animate: false,
title: {
text: 'React Native Navigation!'
}
},
}
}
}
],
options: {
topBar: {
visible: false
},
bottomTab: {
text: 'Tab 1',
icon: require('../images/one.png'),
selectedIcon: require('../images/one.png'),
testID: testIDs.FIRST_TAB_BAR_BUTTON
}
}
}
},
{
stack: {
children: [
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 2'
}
}
}
],
options: {
bottomTab: {
text: 'Tab 2',
icon: require('../images/two.png'),
testID: testIDs.SECOND_TAB_BAR_BUTTON
}
}
}
},
{
component: {
name: 'navigation.playground.TextScreen',
passProps: {
text: 'This is tab 3',
myFunction: () => 'Hello from a function!'
},
options: {
topBar: {
visible: true,
animate: false
},
bottomTab: {
text: 'Tab 3',
icon: require('../images/one.png'),
selectedIcon: require('../images/one.png')
}
}
}
}
],
options: {
bottomTabs: {
titleDisplayMode: 'alwaysShow',
testID: testIDs.BOTTOM_TABS_ELEMENT
}
}
}
}
});
如您所见,BottomTab选项可以在堆栈选项或组件的选项中声明。
这是因为从每个选项卡的当前布局树中解析选项。
重要的是要记住,选项是自下而上解决的,这意味着从根开始声明的更深的选项优先于更靠近根的更高的选项
让我们仔细看看BottomTab的第一个子项。在本例中,它是一个声明bottomTab选项的堆栈。推到此堆栈的任何子级都可以覆盖堆栈的底部选项卡选项,因为它在布局树中较深-堆栈的选项可以视为默认选项。这不是一个真正的答案,但我建议改用react导航,API更简单,您可以将ActiveColor传递给导航堆栈,而不是单个组件。这不是一个真正的答案,但我建议使用react导航,API更简单,您可以将ActiveColor传递给导航堆栈,而不是单个组件。Ohh,以便了解其工作原理!这让事情变得更加清楚:有没有一种方法可以合并子组件中的选项,而不是覆盖它?好吧,你可以调用合并更新组件选项。我的意思是在你创建“静态”时structure@guy.gc如果我想隐藏android和ios的按钮文本标签,我们应该怎么做?已尝试使用标题显示模式:android和iConSets的“alwaysHide:{top:0,left:0,bottom:0,right:0}用于ios,但似乎不起作用。我们还需要做其他事情吗?只是不要为标签设置标题。只有图标是底部标签项必须的。哦,这就是它的工作原理!这让事情变得更加清楚:有没有一种方法可以合并子组件中的选项,而不是覆盖它?好吧,你可以调用合并更新组件选项。我的意思是在你创建“静态”时structure@guy.gc如果我想隐藏android和ios的按钮文本标签,我们应该怎么做?已尝试使用标题显示模式:android和iConSets的“alwaysHide:{top:0,left:0,bottom:0,right:0}用于ios,但似乎不起作用。我们还需要做其他事情吗?只是不要为标签设置标题。对于底部选项卡项,只有图标是必需的。