Routing durandal路由错误';无法读取属性';然后';未定义的';,这是什么意思?
我是杜兰达尔的新手,刚刚开始。我开始使用示例应用程序并开始修改它,但在路由时遇到此错误,我被卡住了,请帮助: 堆栈跟踪: 未捕获的TypeError:无法读取未定义的属性“then” activator.js?bust=1386627525810:141(匿名函数) activator.js?bust=1386627525810:141 jQuery.extend.Deferred jquery-1.9.1.js:1248 system.defer system.js?bust=1386627525810:218 canDeactivateItem activator.js?胸围=1386627525810:130 computed.canDeactivateItem activator.js?胸围=1386627525810:240 (匿名函数)activator.js?bust=1386627525810:300 jQuery.extend.Deferred jQuery-1.9.1.js:1248 system.Deferred system.js?bust=1386627525810:218 computed.activateItem activator.js?胸围=1386627525810:285 activateRoute router.js?bust=1386627525810:257重新激活 router.js?bust=1386627525810:328(匿名函数) router.js?bust=1386627525810:360(匿名函数) jquery-1.9.1.js:1192 fire jquery-1.9.1.js:1037 self.fireith jquery-1.9.1.js:1148延迟(匿名函数) jquery-1.9.1.js:1237(匿名函数) 我的Shell.js看起来像:Routing durandal路由错误';无法读取属性';然后';未定义的';,这是什么意思?,routing,durandal,Routing,Durandal,我是杜兰达尔的新手,刚刚开始。我开始使用示例应用程序并开始修改它,但在路由时遇到此错误,我被卡住了,请帮助: 堆栈跟踪: 未捕获的TypeError:无法读取未定义的属性“then” activator.js?bust=1386627525810:141(匿名函数) activator.js?bust=1386627525810:141 jQuery.extend.Deferred jquery-1.9.1.js:1248 system.defer system.js?bust=13866275
define(['plugins/router', 'durandal/app'], function (router, app) {
return {
router: router,
search: function() {
//It's really easy to show a message box.
//You can add custom options too. Also, it returns a promise for the user's response.
app.showMessage('Search not yet implemented...');
},
activate: function () {
router.map([
{ route: '', title: 'Budget', moduleId: 'viewmodels/budget' },
{ route: 'Back', title: 'Back to User Screens', moduleId: 'viewmodels/back', nav: true },
{ route: 'Budget', title: 'Budget', moduleId: 'viewmodels/budget', nav: true },
]).buildNavigationModel();
return router.activate();
}
};
});
Back.js和Back.html基本上是空的,就像这样,我想让这个页面做的就是重定向回我的旧应用程序,我希望durandal成为我正在构建的应用程序的一个新部分,我正在考虑慢慢地将所有内容迁移到durandal中:
define(['plugins/http', 'durandal/app', 'knockout'], function (http, app, ko) {
//Note: This module exports an object.
//That means that every module that "requires" it will get the same object instance.
//If you wish to be able to create multiple instances, instead export a function.
//See the "welcome" module for an example of function export.
return {
};
});
back.html:
<section>
<script language="javascript">
window.location.replace('/Project');
</script>
</section>
window.location.replace('/Project');
有什么想法/解释吗?任何关于如何进一步调试的建议都将不胜感激
则
通常与一个类似的库相关联。它基本上是说异步运行一个函数,然后运行传入的函数。由于正在运行的函数没有返回承诺或返回其他内容,或者可能什么都没有,因此您遇到的错误将被忽略
查看您提供的Back.js文件,它至少需要有一个activate函数,durandal才能正确加载页面,我认为这将是您的主要问题
define(['plugins/http', 'durandal/app', 'knockout'], function (http, app, ko) {
//Note: This module exports an object.
//That means that every module that "requires" it will get the same object instance.
//If you wish to be able to create multiple instances, instead export a function.
//See the "welcome" module for an example of function export.
var vm = {
activate: activate
};
return vm;
function activate() {
return true;
}
});
然后
通常与一个类似的库相关联。它基本上是说异步运行一个函数,然后运行传入的函数。由于正在运行的函数没有返回承诺或返回其他内容,或者可能什么都没有,因此您遇到的错误将被忽略
查看您提供的Back.js文件,它至少需要有一个activate函数,durandal才能正确加载页面,我认为这将是您的主要问题
define(['plugins/http', 'durandal/app', 'knockout'], function (http, app, ko) {
//Note: This module exports an object.
//That means that every module that "requires" it will get the same object instance.
//If you wish to be able to create multiple instances, instead export a function.
//See the "welcome" module for an example of function export.
var vm = {
activate: activate
};
return vm;
function activate() {
return true;
}
});
谢谢示例附带的welcome.js文件没有激活功能,因此我不知道需要激活。然而,即使使用了您发布的代码,我仍然会收到相同的错误。我知道某个地方可能在期待一个承诺,但我如何知道那是什么?解决了问题。因为你试图提供帮助,所以投票给了你,但问题是我移动的页面有这个。candeactivate,我已经注释掉了一个令人讨厌的弹出窗口,它返回了预期会返回的承诺。如果欢迎视图在没有激活的情况下工作,那么我错了。我使用durandal的大多数视图都需要某种激活,所以我习惯于添加它。CanDeactivate也为我解决了这个问题。我已经从另一个模块中粘贴了它,并将其注释掉,直到我准备好使用它。显然,它的存在要求你在继续之前回答是/否问题。谢谢。示例附带的welcome.js文件没有激活功能,因此我不知道需要激活。然而,即使使用了您发布的代码,我仍然会收到相同的错误。我知道某个地方可能在期待一个承诺,但我如何知道那是什么?解决了问题。因为你试图提供帮助,所以投票给了你,但问题是我移动的页面有这个。candeactivate,我已经注释掉了一个令人讨厌的弹出窗口,它返回了预期会返回的承诺。如果欢迎视图在没有激活的情况下工作,那么我错了。我使用durandal的大多数视图都需要某种激活,所以我习惯于添加它。CanDeactivate也为我解决了这个问题。我已经从另一个模块中粘贴了它,并将其注释掉,直到我准备好使用它。显然,它的存在要求你在继续之前回答是/否问题。