我使用 React-Navigation 深度链接从 Url 获取参数,但我想将这些参数传递给一个对象。现在我这样做:
prefixes: [Linking.makeUrl('/'), 'https://test.app', 'https://*.test.app'],
config: {
screens: {
App: {
screens: {
Chat: {
path: 'chat/:firstName/:lastName/:birthdate',
parse: {
firstName: (firstName: string) => decodeURIComponent(firstName),
lastName: (lastName: string) => decodeURIComponent(lastName),
birthdate: (birthdate: string) => decodeURIComponent(birthdate),
},
},
Run Code Online (Sandbox Code Playgroud)
这是结果:
const { firstName, lastName, birthdate} = route.params
Run Code Online (Sandbox Code Playgroud)
我需要的是一个带有名字、姓氏、出生日期的对象:
const { userObject } = route.params
Run Code Online (Sandbox Code Playgroud) parameters deep-linking reactjs react-native react-navigation