![](/img/trans.png)
[英]How to navigate between different nested stacks in react navigation - react native
[英]React native navigation single modal, navigate to different content
我正在寻找一种方法来让多个屏幕的演示模式为“模态”,但在调用 navigation.navigate 时不会弹出 2 个模态。
<Stack.Screen name="Results" component={ResultsScreen} options={{ presentation:'modal'}} />
<Stack.Screen name="Viewer" component={ViewerScreen} options={{presentation:'modal'}} />
默认功能似乎是在彼此之上打开 2 个单独的模式窗口。 我想打开一个单一的模态并改变模态的内容。 这可能吗?
您可以尝试使用嵌套堆栈导航器
const ModalStackView = () => (
<ModalStack.Navigator
screenOptions={{
headerShown: true,
}}>
<ModalStack.Screen
name="modalCard1"
component={ModalView}
options={{presentation: 'modal'}}
/>
<ModalStack.Screen
name="modalCard2"
component={CardView}
options={{presentation: 'card'}}
/>
</ModalStack.Navigator>
)
<RootStack.Group screenOptions={{ presentation: 'modal' }}>
<RootStack.Screen name="MyModal" component={ModalStackView} />
</RootStack.Group>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.