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' }
]);
}
}
你的目的的重要行是这两个:
// 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