TSR*_*TSR 14 aurelia aurelia-navigation aurelia-router
在应用程序中,我希望导航到home/contract-view/10一个动作.试着
this.router.navigateToRoute(`home/contract-view`, { id: 10}, { absolute: true });
失败了 Route home/contract-view not be found
另一个尝试:
this.router.navigate(`#/home/contract-view`, { id: 10});
失败了Route not found: contract-view(…)
如何实现这一目标?App.ts:
configureRouter(config: RouterConfiguration, router: Router) {
        config.title = 'Contracts Portal';
        config.map([
            { route: ['', 'dummy'], name: 'dummy', moduleId: 'dummy', nav: false, title: 'Dummy', settings: { pos: 'left' } },
            { route: 'home', name: 'home', moduleId: 'home', nav: true, title: 'Home', settings:{pos: 'left', class: 'home' }, auth: true },
        ]);
        this.router = router;    
    }
Home.ts:
 configureRouter(config: RouterConfiguration, router: Router) {
        config.map([
            { route: ['', 'contract-view/:id'], name: 'contract-view', moduleId: 'contract-view', nav: true, title: 'Contract' },
            { route:  'doc-view/:id', name: 'doc-view', href:'doc-view', moduleId: 'doc-view', nav: true, title: 'Document' },
        ]);
        this.router = router;
        this.router.refreshNavigation();
    }
wea*_*e08 38
首选解决方案是使用您在路由器中配置的命名路由.
this.router.navigateToRoute('contract-view', {id: 10});
您配置了"home"中的路由器contract-view/:id,因此您需要this.router.navigate('home/contract-view/10').并尝试删除this.router.refreshNavigation()过于
| 归档时间: | 
 | 
| 查看次数: | 15038 次 | 
| 最近记录: |