如何在不更改 Ember 中的 URL 的情况下将路由放入子文件夹中

How to put routes in a sub folder without changing the URL in Ember

我有一些链接目前在我的主路径中。我想在不更改 url 的情况下将它们分组到一个子文件夹中。例如,我有 /income-statement 并且我想将文件放在报告目录中。对于嵌套路由,url 变为 /reports/income-statement。我尝试将报告级别的路径设置为 {path: ''} 但它与我的主要路线冲突

this.route('reports', function() {
  this.route('accounts-receivable')
  this.route('income-statement')
})

我发现我可以通过在路径的开头添加 ../ 来完成此操作

this.route('reports', function() {
  this.route('accounts-receivable', {path: '../accounts-receivable'})
  this.route('income-statement', {path: '../income-statement'})
})

将您的组路由路径指定为 /:

this.route('reports', { path: '/' }, function() {
  this.route('accounts-receivable')
  this.route('income-statement')
});