我嘗試遷移現有Ember.js項目中使用Ember App Kit
,我看到了一些奇怪的錯誤,我認爲不應該發生在這裏...灰燼應用套件:路由器#updatePaths引發TypeError
如果我開始應用程序,一切都已初始化,我的util類已啓動並運行,併發送和接收Ajax請求 - 一切都很順利。但後來我一直在一遍又一遍的得到同樣的錯誤:
Uncaught TypeError: Cannot read property 'name' of undefined
如果我跟着下來的堆棧跟蹤我來看看,在Router
的updatePaths()
功能發生錯誤(我評論了行,其中的代碼啓動失敗:
function updatePaths(router) {
var appController = router.container.lookup('controller:application');
if (!appController) {
// appController might not exist when top-level loading/error
// substates have been entered since ApplicationRoute hasn't
// actually been entered at that point.
return;
}
var infos = router.router.currentHandlerInfos, // <-- empty Array ([])
path = Ember.Router._routePath(infos); // <-- empty String ("")
if (!('currentPath' in appController)) {
defineProperty(appController, 'currentPath');
}
set(appController, 'currentPath', path);
if (!('currentRouteName' in appController)) {
defineProperty(appController, 'currentRouteName');
}
set(appController, 'currentRouteName', infos[infos.length - 1].name); // throws Uncaught TypeError: Cannot read property 'name' of undefined
}
這裏是堆棧跟蹤:
Uncaught TypeError: Cannot read property 'name' of undefined ember.js:35015
updatePaths ember.js:35015
Ember.Router.Ember.Object.extend.intermediateTransitionTo ember.js:34522
(anonymous function) ember.js:34919
forEachRouteAbove ember.js:34869
defaultActionHandlers.loading ember.js:34915
triggerEvent ember.js:34983
trigger ember.js:34116
Transition.trigger ember.js:33952
Ember.Router.Ember.Object.extend._fireLoadingEvent ember.js:34750
DeferredActionQueues.flush ember.js:5893
Backburner.end ember.js:5984
Backburner.run ember.js:6023
Ember.run ember.js:6426
runInitialize ember.js:39637
jQuery.Callbacks.fire jquery.js:3063
jQuery.Callbacks.self.fireWith jquery.js:3175
jQuery.extend.ready jquery.js:3381
completed jquery.js:3397
而且,似乎appController
不我在我的ApplicationController
但如從燼本身產生的控制器並不能明白爲什麼(我ApplicationController
在app/controllers/application.js
定義...
有誰知道有關此問題的任何東西,或能告訴我正確的方向追蹤莫名其妙地解決這個錯誤?
您可以使用plzz再生jsbin或發佈stacktrace..that將是有益的.. – thecodejack
@CodeJack我在我原來的文章中添加了堆棧跟蹤 - 不幸的是我想不出任何解決方案來創建一個Ember應用套件jsbin :( – herom