gpt4 book ai didi

Aurelia 路由器导航和导航到路由

转载 作者:行者123 更新时间:2023-12-03 21:03:59 24 4
gpt4 key购买 nike

在 app.ts 我希望导航到 home/contract-view/10在一个 Action 上。试过

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(…)如何实现这一目标?
应用程序:
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;
}

主页.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();
}

最佳答案

首选的解决方案是使用您在路由器中配置的命名路由。

this.router.navigateToRoute('contract-view', {id: 10});

关于Aurelia 路由器导航和导航到路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35955734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com