2016-09-20 86 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