react-native - 开发环境中的博览会和反应导航深层链接-我做错了什么?
问题描述
一旦用户单击 webview/iframe 中的链接,我试图让 webview 重定向到不同的屏幕。
Screens.js
const AppStack = createBottomTabNavigator(
{
Ritual: {
screen: RitualScreen,
},
Home: {
screen: HomeScreen,
},
NewsFeed: {
screen: WallScreen,
path: 'newsfeed'
}...
const AppContainer = createAppContainer(
createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: {screen: AppStack, path: 'home'},
Auth: AuthStack
},
{
initialRouteName: 'AuthLoading',
}
)
);
export default AppContainer;
然后在RitualScreen
哪个页面上加载应用程序时加载的页面.. 在 web 视图中加载调查。当用户单击FINISH
链接时,我希望将用户重定向到新闻源,例如:我认为这是:
exp://localhost:19000/home/newsfeed
- 但除了一个空的路径(exp:// localhost:19000)之外的任何路径都会中断..我错过了什么?
我知道在生产中我需要将域更改为我的方案,例如 myapp:// 或使用自动更改 uri 中前缀的链接方法。
但现在我只想让它在开发环境中工作。
解决方案
我想我已经找到了解决办法——虽然它很厚颜无耻,哈哈
呈现 Webview 的屏幕...
20 render() {
21 return (
22
32 <WebView
33 onNavigationStateChange={
(e) => {
if(e.url == "https://www.google.com/") this.props.navigation.navigate("NewsFeed")
}
}
34 source={{ uri: 'https://s.surveyanyplace.com/a-path-to-load' }} style={styles.WebView} />
37 )
38 };
39 }
因此,本质上是在它即将发生之前捕获到特定路径的重定向,并使用 react navigator 转到应用程序内的屏幕。
推荐阅读
- docker - 如何在生产设备中安全地使用 docker 容器注册表凭证
- flutter - 使 TextField 的某些部分可编辑
- reactjs - 从反应访问 Json 文件中的嵌套数组对象
- powershell - 在多个文件上运行 Powershell 脚本
- windows - 连接apache directory studio的问题(LDAP认证失败)
- javascript - WordPress 搜索不起作用 - DIVI 和 Elementor
- angular - Angular 视图封装与外部库
- agora.io - Agora 云录制不录制发布者(直播中的主持人)
- angular - 在哪里可以找到 Angular 中的 Microsoft Azure msal 注册?
- python-3.x - 将 sqilte 文件推送到公共仓库是否安全?