Aurelia 基于路径而不是哈希值定义路由
Aurelia路由器将路由映射到Aurelia 基于路径而不是哈希值定义路由,aurelia,Aurelia,Aurelia路由器将路由映射到散列 如何根据pathA/pathB/pathC值定义Aurelia路由?您可以设置推送状态。我们在这里的文档中讨论了这一点:您可以设置推送状态。这在我们的文档中进行了讨论:以下是文档中的一个示例。但是为了使散列有效,您需要将config.options.hashChange指定为false: import {Redirect, NavigationInstruction, RouterConfiguration} from 'aurelia-router';
散列
如何根据
pathA/pathB/pathC
值定义Aurelia路由?您可以设置推送状态。我们在这里的文档中讨论了这一点:您可以设置推送状态。这在我们的文档中进行了讨论:以下是文档中的一个示例。但是为了使散列有效,您需要将config.options.hashChange指定为false:
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;
下面是文档中的一个示例。但是为了使散列有效,您需要将config.options.hashChange指定为false:
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;