2016-12-01 129 views
0

我有兩個孩子應用程序「Solace」和「UM」,我打算擁有自己的路由器。我的主要應用程序是「mcc-gui」。無法導航到aurelia中的子路由器路由

目前,我試圖在主路由器中定義的路由「mcc-gui/um」導航到子路由器(即UM的路由器),但我無法做到這一點。

我確實收到錯誤「Unexpected token <」,而不是因爲找不到路由。

然而,當我使用路由mcc-gui/solace/devices直接從主路由器對另一個子應用程序「Solace」進行渲染時,會顯示所需的視圖。

這是我的主路由器app.js:

export class App { 
    configureRouter(config,router){ 
     config.title = 'MCC GUI'; 
     config.options.pushState=true; 
     config.map(
      [ 
      {route: '', name:'default',redirect: 'mcc-gui/solace/devices'}, 
{route: 'mcc-gui/solace/devices', name:'solace_devices',moduleId: './sections/middleware/solace/devices/devices', nav: true, title: 'Devices',settings:{icon: 'fa fa-server'}}, 
      {route: 'mcc-gui/um', name:'um', title: 'UM', moduleId: './sections/middleware/um/main', nav: true, settings:{icon: 'glyphicon-road'}}, 

     ]); 
     this.router=router; 
    } 
} 

這是我的孩子路由器main.js(MCC-GUI的\ src \段內\中間件\ UM)

export class Main { 

    configureRouter(config,router){ 
    config.title = 'MCC For UltraMessaging!'; 
    config.options.pushState=true; 

    config.map([ 
        {route: '', name:'default', redirect: 'transports'}, 

        {route: 'transports', name:'transports', moduleId: './transports/transports', nav: true, title: 'Transports',settings:{icon: 'glyphicon-road'}} 


       ]); 
    this.router=router; 
    } 
} 

這是我的main.html中

<template> 
     <require from='./nav-bar'></require> 

     <!--<nav-bar router.bind="router"></nav-bar>--> 

     <div class="page-host"> 
     <router-view></router-view> 
     </div> 
    </template> 

這是我的項目佈局: C:\ dev的\ messagingcommandcenter \ MCC-GUI \ htdocs中\ MCC-GUI的\ src>樹

 ├───sections 
     │ └─── middleware 
     │  ├───solace 
     │  │ ├───connections 
     │  │ └───devices 
     │  └───um 
     │   ├───receivers 
     │   ├───sources 
     │   └───transports 
     |   |  | 
     |   |  |--transports.html 
     |   |   transports.js 
     |   |  
     |   |---main.html 
     |    main.js 
     |    nav-bar.html 
     |    nav-bar.js 
     |  
     |--.eslintrc 
      app.html 
      app.js  
      main.js 
      nav-bar.html 
      nav-bar.js 

回答

0

在我看來,在你已經在你的App類配置的路由器 - 你正在做一個重定向到一個不存在的路線。

+0

道歉,剛剛編輯了這個問題。主路由器中有很多路由,所以我們決定把它分解成子路由器/應用。在發佈這個問題時,我們清理了一些路由器代碼,以便更容易閱讀。 –