Aurelia How do I use a Child Router and dynamics child routes

て烟熏妆下的殇ゞ 提交于 2019-12-06 15:38:17

In your example, you are injecting the router, which is the router configured in app.js, and then calling its configure method. Aurelia is Convention-Over-Configuration. So, use the convention and you will be fine. The configureRouter method will do the tricks for you. For instance:

export class ScreensList {

  configureRouter(config, router) {
    config.map([
      { route: 'screen/:id',  moduleId: 'screens/screen/display',  name: 'screen', title: 'Screen #1' }
    ]);

    this.router = router;
  }

}

Remember that ScreensList must be a screen of your router. It will not work if it is a custom element.

Take a look at the skeleton-navigation examples https://github.com/aurelia/skeleton-navigation. There are good examples, including child routing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!