【问题标题】:Expo deep linking in React Native WebReact Native Web 中的 Expo 深度链接
【发布时间】:2020-12-25 01:50:32
【问题描述】:

尝试为 React Native Web 进行深度链接。浏览了很多文章,终于找到了针对这个 link 中面临的确切问题提出的解决方案,这对我不起作用。

世博会文档说使用

const prefix = Linking.makeUrl('/')

并在 AppNavigator 中设置前缀。

想知道在使用单击链接时如何指向我的 react 本机 Web 应用程序。问题是 Linking.makeUrl('/') 在我的笔记本电脑上返回 exp://localhost:19006/ 。由于浏览器无法识别 exp 作为方案无法打开我的 URL。

我尝试在 app.json 中将方案设置为 https,但 Linking.makeUrl('/') 仍将方案返回为 expo。

在我的应用程序中,当用户单击我在应用程序中加载的静态 html 页面时,我想路由回我的应用程序。由于我无法使用 Expo 获得正确的 React Native Web 方案,因此无法进一步进行。

谢谢。

附上链接中提供的代码。

import React from 'react'
import { createSwitchNavigator } from '@react-navigation/core'
import { createBrowserApp } from "@react-navigation/web"
import { Linking } from 'expo'

const prefix = Linking.makeUrl('/')
const AppNavigator = createBrowserApp(createSwitchNavigator({
  Landing: {
    screen: LandingScreen,
    path: '/'
  },
  Login: {
    screen: LoginScreen,
    path: 'login'
}
}, {
  initialRouteName: 'Landing',
  backBehavior: 'history'
}))
export default () => <AppNavigator uriPrefix={prefix} />

【问题讨论】:

  • 运气好吗?我正在尝试自己解决这个问题。
  • 嗨,Ox,我无法弄清楚,因为当时我正在将它用于其他一些功能。

标签: react-native expo react-navigation react-native-deep-linking


【解决方案1】:

尝试: const prefix = Linking.createURL('/');

【讨论】:

  • 虽然此代码可能会回答问题,但提供有关此代码为何和/或如何回答问题的额外上下文可提高其长期价值。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-03
相关资源
最近更新 更多