【发布时间】:2015-12-17 17:51:05
【问题描述】:
以下是我的看法:
1.app - 标准
2. home - 左侧有一个项目列表,选择任何一个,将在路由器视图的右侧显示一些内容(要加载的合同视图)。
3.contract-view
app.ts:路由配置:
configureRouter(config: RouterConfiguration, router: Router) {
config.title = 'Contracts Portal';
config.map([
{ route: ['', 'home'], name: 'home', moduleId: 'home', nav: true, title: 'Home' },
{ route: 'resources', name: 'resources', moduleId: 'resources', nav: true, title: 'Resources' },
{ route: 'tools', name: 'tools', moduleId: 'tools', nav: true, title: 'Tools' }
]);
this.router = router;
}
Home.ts 路由器配置:
configureRouter(config: RouterConfiguration, router: Router) {
config.title = "test";
config.map([
{ route: ['', 'contract-view/:id'], name: 'contract-view', moduleId: 'contract-view', nav: true, title: 'Test' }
]);
this.router = router;
}
在主页列表中选择一个项目时,我正在尝试如下导航以在右窗格的路由器视图中加载内容home.ts:
this.router.navigateToRoute("contract-view", { id: 4090 });
但是它抛出错误:找不到路由:/contract-view/4090
此时,它仍然是主页和默认路由,因此 url 显示为:http://localhost:9000/#/
所以它失败了。
但是,如果我手动将 url 更改为 http://localhost:9000/#/home 然后选择一个列表项,导航到合同视图就可以了。
我在这里错过了什么?
我正在寻找绝对路径导航。尝试导航到 home/contract-view 但失败并出现错误:
找不到名为“home/contract-view”的路由。检查名称:home/contract-view 已在路由配置中指定。
【问题讨论】:
标签: aurelia