Aurelia:子路由器导航:找不到路由 [英] Aurelia: Child Router Navigation: Route not found

查看:102
本文介绍了Aurelia:子路由器导航:找不到路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的观点:1. app -标准2. home -在左侧有一个项目列表,选择任何项目后,将在路由器视图(要加载的合同视图)的右侧显示一些内容.3. contract-view

Below are my views: 1. app - standard 2. home - Has a list of items on left, on selection of any, will display some content on the right side in router-view (contract-view to be loaded). 3. contract-view

app.ts:路由配置:

app.ts: route Config:

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路由器配置:

Home.ts Router Config:

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 中:

on selection of a item in home page list, I am trying to navigate as below to load content in the right pane's router-view, in home.ts:

this.router.navigateToRoute("contract-view", { id: 4090 });

但是它引发错误:找不到路由:/contract-view/4090

However it throws the error: Route not found: /contract-view/4090

此时,它仍然是主页和默认路由,因此url读取为: http://localhost:9000/#/因此失败了.但是,如果我手动将URL更改为 http://localhost:9000/#/home ,然后选择一个列表项,则导航至合同视图即可.我在这里想念我什么?

At this point, it's still home page and default route, hence the url reads: http://localhost:9000/#/ and so it fails. But, if I manually change the url to http://localhost:9000/#/home and then select a list item, navigation to contract-view works. What I am I missing here?

我正在寻找绝对路径导航.尝试导航到 home/contract-view ,但失败并显示以下错误:找不到名称为"home/contract-view"的路由.检查名称:在路由的配置中指定了 home/contract-view .

I am looking for absolute path navigation. Tried navigating to home/contract-view but fails with error: A route with name 'home/contract-view' could not be found. Check that name: home/contract-view was specified in the route's config.

推荐答案

Aurelia Router框架存在问题.此处的讨论和解决方法: https://github.com/aurelia/skeleton-navigation/issues/230

It is an issue with Aurelia Router framework. Discussion and workaround here: https://github.com/aurelia/skeleton-navigation/issues/230

这篇关于Aurelia:子路由器导航:找不到路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆