在 Web 上响应导航
对网络的支持是实验性的并且正在进行中。它存在错误,缺少许多功能,并且用于 Web 集成的 API 可能会在次要版本中发生更改。请帮助我们测试它,如果遇到错误,请打开错误报告。
¥Support for web is experimental and a work in progress. It has bugs, is missing many features and the API for web integration may change in minor versions. Please help us test it and open bug reports if you encounter a bug.
React Navigation 的 Web 支持当前需要使用 面向 Web 的 React Native。这种方法让我们可以在 React Native 和 Web 上重用相同的代码。
¥React Navigation's web support currently requires using React Native for Web. This approach lets us reuse the same code on both React Native and Web.
目前,可以使用以下功能:
¥Currently, the following features are available:
使用链接作为主要导航方式(而不是 navigation.navigate
等导航操作)非常重要。它将确保你的链接在网络上可以正确使用。
¥It's important to use links as the primary way of navigation instead of navigation actions such as navigation.navigate
. It'll ensure that your links are properly usable on web.
一些导航器在网络上的配置也不同,或者提供额外的网络特定功能:
¥Some of the navigators are also configured differently on web or provide additional web specific features:
-
drawer 和 底部选项卡 导航器分别在抽屉侧边栏和选项卡栏中显示超链接。
¥The drawer and bottom tab navigators show hyperlinks in the drawer sidebar and tab bar respectively.
-
在 Web 上使用时,滑动手势在 drawer 和 stack 导航器上不可用。
¥Swipe gestures are not available on drawer and stack navigators when using on the web.
-
默认情况下,stack 导航器禁用页面转换动画,但可以通过指定
animationEnabled: true
重新启用它。¥By default, stack navigator disables page transition animations, but it can be re-enabled by specifying
animationEnabled: true
.
与 React Navigation 4 不同,在使用 React Native for Web 时,你不需要安装单独的包来使用 Web 集成。如果你安装了 @react-navigation/web
软件包,请卸载它,因为它无法与 React Navigation 6 一起使用。
¥Unlike React Navigation 4, you don't need to install a separate package to use web integration when using React Native for Web. If you have the @react-navigation/web
package installed, please uninstall it because it cannot be used with React Navigation 6.