gpt4 book ai didi

reactjs - 使用 Deeplinking 和 React-Navigation-5 获取前缀后的所有内容作为参数

转载 作者:行者123 更新时间:2023-12-05 06:56:46 25 4
gpt4 key购买 nike

我正在使用 react-navigation-5 和深层链接。我想提取深层链接前缀后的所有内容并将其作为参数传递。

我有以下内容

const deeplinking = {
prefixes: ['myapp://'],
config: {
Store: {
path:'store/:url' ,
params: {
url: null,
},
}
}
};

return (
<NavigationContainer linking={deeplinking}>
<Stack.Navigator initialRouteName="Splash" screenOptions={{ headerShown: false, cardStyle: { backgroundColor: '#fff' } }}>
<Stack.Screen name="Splash" component={Splash} />
<Stack.Screen name="Store" component={Store} />

</Stack.Navigator>
</NavigationContainer>
);
}

如果我使用以下深层链接:

myapp://alpha/delta/gamma

url参数变为:

'alpha' 

因此,在传递深度链接时,在前缀之后遇到的第一个正斜杠 / 以及它之后的所有内容都将被删除。

我希望参数(上例中的 url)为:

'alpha/delta/gamma'

我怎样才能做到这一点?

我在这里查看了文档: https://reactnavigation.org/docs/deep-linking/ https://reactnavigation.org/docs/configuring-links/

但是他们没有提到如何处理正斜杠。

最佳答案

  config: {
screens: {
deeplink: {
path: 'deeplink/id',
},
},
},
}
Make deeplink url:
https://example.com/deeplink/details?token=uygiuhiuhpuihpiuyiuhuihhiluhiu

Access token from component:
this.props.route.params.token

result will be =uygiuhiuhpuihpiuyiuhuihhiluhiu

关于reactjs - 使用 Deeplinking 和 React-Navigation-5 获取前缀后的所有内容作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65063415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com