Aureliaルータはルートをhash
にマップします。ハッシュ値にないパスに基づいてルートを定義します。
http://subdomain.hostname.tld/pathA/pathB/pathC?queryKey=queryValue#hash
どのように我々は、代わりにpathA/pathB/pathC
値に基づいて、オーレリアルートを定義することができますか?
Aureliaルータはルートをhash
にマップします。ハッシュ値にないパスに基づいてルートを定義します。
http://subdomain.hostname.tld/pathA/pathB/pathC?queryKey=queryValue#hash
どのように我々は、代わりにpathA/pathB/pathC
値に基づいて、オーレリアルートを定義することができますか?
次はドキュメントの例です。しかし#hashが機能するために、あなたは偽としてconfig.options.hashChangeを指定する必要があります:
import {Redirect, NavigationInstruction, RouterConfiguration} from 'aurelia-router';
export class App {
configureRouter(config: RouterConfiguration): void {
config.title = 'Aurelia';
config.options.pushState = true;
config.options.root = '/';
config.options.hashChange = false;
config.map([
{ route: ['welcome'], name: 'welcome', moduleId: 'welcome', nav: true, title:'Welcome' },
{ route: 'flickr', name: 'flickr', moduleId: 'flickr', nav: true, auth: true },
{ route: 'child-router', name: 'childRouter', moduleId: 'child-router', nav: true, title:'Child Router' },
{ route: '', redirect: 'welcome' }
]);
}
}
あなたの目的のために重要な行は、これらの2つです:
// switch from hash (#) to slash (/) navigation
config.options.root = "/";
config.options.hashChange = false;
プッシュ状態を設定できます。これについては、こちらのドキュメントで説明しています。http://aurelia.io/hub.html#/doc/article/aurelia/router/latest/router-configuration/2