【问题标题】:Using Aurelia, how to use route-href to reference child routes?使用 Aurelia,如何使用 route-href 引用子路由?
【发布时间】:2018-01-01 01:55:54
【问题描述】:

使用 Aurelia,如何使用route-href 构造引用子路由的锚标记 href?

在 app.js 中,定义到父视图的路由。

config.map([
{ 
   route: 'parentview,
   name: 'parentview',
   moduleId: './parentview'
}]);

在 parentview.js 中,配置到子视图的路由:

config.map([
{ 
   route: ['', 'childviewone'], name: 'childviewone', moduleId: './childviewone' },
   route:      'childviewtwo',  name: 'childviewtwo', moduleId: './childviewtwo' }
]);

我发现没有办法使用route-href 构造一个类似于“parentview/childviewone”或“parentview/childviewtwo”的锚标记href。

这似乎是一个简单且可能很常见的场景。也许以下问题正在阻碍?还是我错过了什么?

https://github.com/aurelia/router/issues/89

https://github.com/aurelia/router/issues/90

【问题讨论】:

  • 您目前如何尝试使用route-href
  • @thebluefox 你有什么想法可行吗?

标签: routing aurelia


【解决方案1】:

我认为aurelia-router 目前不支持从父路由器生成到子路由器的 URL。路由配置当前是延迟加载的,因此在显示具有路由配置的组件之前,子路由的路由是未知的。您可以生成到父路由或同一范围内的路由的路由,但不能从另一个子路由或根路由到子路由。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多