HINWEIS passend: pushstate ist aktiviertAurelia Route
Ich habe ein Problem/Frage im Zusammenhang mit aurelia Route Matching. Ich habe folgende Routen in den 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'
}
In den profile.ts Modul, muss ich einen anderen configRoute, wo ich 2 weitere Kind Routen gesetzt, wie:
{
route: ['personal'],
href: '#',
name: 'personal',
moduleId: PLATFORM.moduleName('./personal', 'personal'),
title: 'Personal'
},
{
route: ['skills'],
href: '#',
name: 'skills',
moduleId: PLATFORM.moduleName('./skills', 'skills'),
title: 'Skills'
}
Das Problem ist folgendes: Wenn ich zu /profile/skills
oder /profile/personal
navigiere, wird die Route den Ländern eins (':continents/:countries'
) entsprechen. Was ich für sinnvoll halte, weil das ganze Segment dazu passt.
Ich konnte das Profil Route meine Routen wäre wie /profile/personal/personal
oder /profile/personal/skills
, die ich nicht will
{
route: ['profile', 'profile/:tabName'],
href: '#',
name: 'profile',
moduleId: PLATFORM.moduleName('../pages/profile', 'profile'),
title: 'Profile'
},
aber dann
ändern.Ich habe versucht, das Wildcard-Symbol hinzuzufügen, wie in dem aurelia docs vorgeschlagen:
{
route: ['profile', 'profile/*tabName'],
href: '#',
name: 'profile',
moduleId: PLATFORM.moduleName('../pages/profile', 'profile'),
title: 'Profile'
},
aber eine Route wie /profile/skills
hat es nicht überein, und es ging noch auf die ':continents/:countries'
.
Kann ich es irgendwie zwingen, auf die profile
Seite zu gehen? (abgesehen von Kind-Routing 'countries'
)
Ja, das ist mein letzter Ausweg für jetzt :). Danke für deinen Beitrag. Wie kommt es, dass die Parametrisierung ('profile /: tabName') die beabsichtigte Route abfing (Profil, obwohl mit einer verwirrten URL) und der Platzhalter nicht? – Zubzob
B/c Wenn Sie dem Router mitteilen, dass er nach einem Parameter suchen soll, dann sucht er nach 'profile /.+' –
Endergebnis ist, dass der ': foo /: bar'-Stil der Route nicht für Sie funktioniert Dein Root-Router. –