2016-09-20 84 views
3

我有以下代碼,基本上是app.js中的主要路由器和儀表板js中的子路由器。每當我去根URL'/'我在瀏覽器控制檯中得到一個警告。我不明白這裏有什麼問題,重定向甚至可以正常工作,並顯示所有內容,但我仍然得到這個巨大的警告,告訴我出了問題。我錯過了什麼?任何幫助讚賞。帶兒童路由器的Aurelia-Router顯示警告

瀏覽器控制檯的警告

Warning: a promise was rejected with a non-error: [object Object] 
    at _buildNavigationPlan (http://localhost:9000/scripts/vendor-bundle.js:14942:22) 
    at BuildNavigationPlanStep.run (http://localhost:9000/scripts/vendor-bundle.js:14922:14) 
    at next (http://localhost:9000/scripts/vendor-bundle.js:14488:20) 
    at Pipeline.run (http://localhost:9000/scripts/vendor-bundle.js:14501:14) 
    at http://localhost:9000/scripts/vendor-bundle.js:16050:25 
From previous event: 
    at AppRouter._dequeueInstruction (http://localhost:9000/scripts/vendor-bundle.js:16023:32) 
    at http://localhost:9000/scripts/vendor-bundle.js:16014:17 
From previous event: 
    at AppRouter._queueInstruction (http://localhost:9000/scripts/vendor-bundle.js:16011:14) 
    at http://localhost:9000/scripts/vendor-bundle.js:15945:23 
From previous event: 
    at AppRouter.loadUrl (http://localhost:9000/scripts/vendor-bundle.js:15944:53) 
    at BrowserHistory._loadUrl (http://localhost:9000/scripts/vendor-bundle.js:11474:55) 
    at BrowserHistory._checkUrl (http://localhost:9000/scripts/vendor-bundle.js:11467:14) 

app.js

export class App { 
    configureRouter(config, router) { 
    this.router = router; 

    config.map([ 
     { route: '', redirect: 'dashboard' }, 
     { route: 'dashboard', name: 'dashboard', title: 'Dashboard', moduleId: 'views/dashboard', auth: true } 
    ]); 
    } 
} 

app.html

<template> 
    <require from="material-design-lite/material.css"></require> 
    <router-view></router-view> 
</template> 

dashboard.js

export class Dashboard { 
    configureRouter(config, router) { 
     this.router = router; 

     config.map([ 
      { route: 'fairs', name: 'fairs', title: 'Messen', moduleId: 'views/fairs', nav: true }, 
      { route: '', redirect: 'fairs' } 
     ]); 
    } 

    attached() { 
     componentHandler.upgradeAllRegistered(); 
    } 
} 

dashboard.html

<template> 
    <router-view></router-view> 
</template> 
+0

可能是你的'dashboard.js'附加方法失敗,導致漣漪錯誤? – Andrew

+1

即使沒有任何附加的方法,我也會得到同樣的錯誤,它確實來自重定向,因爲只有當我訪問/ url時,錯誤纔會顯示,如果我訪問完整的URL /儀表板/任何,沒有錯誤。 – QuantumDream

回答

5

我一直在尋找到同樣的事情,我認爲這是寫的是故意。導致警告的代碼來自組成AppRouter對象的長鏈承諾。

由於重定向步驟被該鏈中的不同方法所控制,因此當它到達步驟BuildNavigationPlanStep.run(...)時,該特定承諾被拒絕,因爲它處於上游(RedirectToRoute.navigate(...))。這是我讀完堆棧跟蹤後的最佳猜測。

我假設警告正在從藍鳥承諾api打印到控制檯,但我不是100%確定。

+1

我實際上已經用了相當長的時間,現在我得到了和你一樣的結論,似乎有一些地方的不同事情被拒絕,而不是「錯誤」,這就是導致這些警告的原因,但是實際上並不意味着什麼是錯誤的,只是一個實現默認值(aurelia-fetch-client實際上與默認值完全相同)。猜猜我們現在應該忽略他們:)謝謝 – QuantumDream