2016-07-29 32 views

回答

4

下面是来自文档的示例。但为了在#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;