【发布时间】:2017-12-26 13:18:02
【问题描述】:
注意:pushState 已启用
我有一个与 aurelia 路由匹配相关的问题。我在 app.ts 中有以下路线:
{
route: ['profile'],
href: '#',
name: 'profile',
moduleId: PLATFORM.moduleName('../pages/profile', 'profile'),
title: 'Profile'
},
{
route: [':continents/:countries'],
name: 'countries',
moduleId: PLATFORM.moduleName('../pages/countries', 'countries'),
title: 'Countries'
}
在 profile.ts 模块中,我做了另一个 configRoute,我在其中设置了另外 2 个子路由,例如:
{
route: ['personal'],
href: '#',
name: 'personal',
moduleId: PLATFORM.moduleName('./personal', 'personal'),
title: 'Personal'
},
{
route: ['skills'],
href: '#',
name: 'skills',
moduleId: PLATFORM.moduleName('./skills', 'skills'),
title: 'Skills'
}
问题如下:当我导航到/profile/skills 或/profile/personal 时,路线将匹配国家一(':continents/:countries')。我认为这是有道理的,因为整个片段都符合这一点。
我可以将个人资料路线更改为
{
route: ['profile', 'profile/:tabName'],
href: '#',
name: 'profile',
moduleId: PLATFORM.moduleName('../pages/profile', 'profile'),
title: 'Profile'
},
但是我的路线会像 /profile/personal/personal 或 /profile/personal/skills 我不想要。
我已尝试按照 aurelia 文档中的建议添加通配符:
{
route: ['profile', 'profile/*tabName'],
href: '#',
name: 'profile',
moduleId: PLATFORM.moduleName('../pages/profile', 'profile'),
title: 'Profile'
},
但是像/profile/skills 这样的路由不匹配它,它仍然去了':continents/:countries'。
我可以强制它转到profile 页面吗? (除了子路由'countries')
【问题讨论】: