【发布时间】:2019-08-27 20:38:43
【问题描述】:
实际上,我正在使用 react-navigation 3.1.5 在 react-native 0.58 上开发应用,但我无法让我的应用正常运行。
这是我的代码:
app-navigation.js
const MainStack = createBottomTabNavigator({
Home: { screen: Home },
Pets: { screen: Pets, path: 'spidersecurity://terque/pets' },
Notifications: { screen: UserNotifications },
UpdateUser: { screen: UpdateUser },
});
const AppStack = createStackNavigator({
MainStack: { screen: MainStack, path: '' },
PetStack: { screen: PetStack }
});
const Main = createSwithNavigator({
App: { screen: AppStack, path: '' }
});
基本上这是我的导航结构。我已将我的AndroidManifest.xml 设置为以下内容:
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="spidersecurity" android:host="terque" />
</intent-filter>
而且,当我打开地址为spidersecurity://terque/pets 的链接时,此链接会打开应用程序,但它不会导航到指定的屏幕。不知道是不是我做的不好,但是我看了很多页面和博客都没有成功。
注意:我已验证 'spidersecurity://terque/pets' 是否是路由匹配,因为我在获取链接时将
console.log添加到我的代码中
【问题讨论】:
-
我认为您还需要设置 AppStack 和 Main 的路径,因为您将屏幕嵌套在其中;并将宠物的路径更改为仅“terque/pets”;删除方案路径。 *** 建议 *** 先尝试一个简单的路径,不要嵌套,直到你得到深度链接。更多信息:reactnavigation.org/docs/en/deep-linking.html
-
如何设置 Main 的路径?并且... AppStack 路径定义为:
'',如果我从 Pets 中删除,我会在其中设置架构。你能提供一个更明确的例子吗? -
@TranQuan 我只尝试了一层深度但仍然无法正常工作
标签: javascript reactjs react-native react-navigation deep-linking