gpt4 book ai didi

angular - Ionic2 深度链接段可选参数

转载 作者:太空狗 更新时间:2023-10-29 17:21:17 24 4
gpt4 key购买 nike

我找不到解释如何在段中使用可选参数的单个文档。

在我的 app.module.ts 中我有这个 deepLinkConfig :

let deepLinkConfig = {
links: [{
component: HomePage, name: 'Home', segment: 'home'
}, {
component: ConnexionPage, name: 'Connexion', segment: 'connexion'
}, {
component: InscriptionPage, name: 'Inscription', segment: 'inscription'
}, {
component: ProfilePage, name: 'Profile', segment: 'profile/:userId'
}, {
component: ExplorePage, name: 'Explore', segment: 'explore'
}, {
component: FAQPage, name: 'FAQ', segment: 'faq'
}]
};

...
imports: [
...
IonicModule.forRoot(MyApp, {}, deepLinkConfig);
],

用户应该能够通过/profile 访问他的个人资料,但也可以通过/profile/:userId 查阅其他用户的个人资料。但是当我尝试访问/profile 时,出现错误:

Uncaught (in promise): invalid views to insert

通过 navCtrl,可以使用空字符串作为 userId 转到“配置文件”,但是一旦您实现该页面,它就会变为空白。

有没有办法让深度链接中的参数可选?

最佳答案

这个问题也有人问过here我认为。

我知道这不是我建议的解决方案,但目前唯一可用的选项是为可选参数使用虚拟值,并在您的代码中处理它。
例如,用户将在 /profile/- 访问自己的个人资料,在 /profile/anyOtherUser 访问其他个人资料。

关于angular - Ionic2 深度链接段可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45543979/

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