Ionic2深度链接段可选参数

Rom*_*ain 8 deep-linking ionic3 angular

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

在我的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);
],
Run Code Online (Sandbox Code Playgroud)

用户应该能够通过访问他的个人资料/profile,但也可以咨询其他用户的个人资料/profile/:userId.但是当我尝试访问/配置文件时,我收到一个错误:

未捕获(承诺):要插入的视图无效

通过navCtrl,可以使用空字符串作为userId转到'profile',但是一旦你实现了页面,它就会变成空白.

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

cha*_*eau 0

我想 这里也有人问过这个问题。

我知道这并不是我提出的解决方案,但目前唯一可用的选择是使用可选参数的虚拟值,并在代码中处理它。
例如,用户可以访问其自己的个人资料(位于 )/profile/-和其他个人资料(位于 )/profile/anyOtherUser