问题:
我的应用程序没有启动;它只是进入一个无限循环。
代码:
我的应用程序开始:
app.start().then(function() {
//Replace 'viewmodels' in the moduleId with 'views' to locate the view.
//Look for partial views in a 'views' folder in the root.
viewLocator.useConvention();
//configure routing
router.useConvention();
router.mapNav('home');
router.mapNav('intro');
router.mapNav('error');
router.mapRoute('set/:id', 'viewmodels/set', 'Set');
router.mapRoute('folder/:id', 'viewmodels/folder', 'Folder');
router.mapRoute('api', 'viewmodels/api', 'API Reference');
app.adaptToDevice();
app.setRoot('viewmodels/intro');
//logger.logError('No route found', route, 'main', true);
/*
router.handleInvalidRoute = function (route, params) {
//debugger;
//router.navigateTo('#/error');
};
*/
});
我将根设置为 intro,其中包含一个具有登录功能的简单视图模型:
define(['durandal/app', 'durandal/plugins/router', 'services/dataservice'], function (app, router, dataservice) {
var introViewModel = function () {
var self = this;
self.router = router;
self.logIn = function () {
app.setRoot('viewmodels/shell');
};
self.activate = function () {
return router.activate('intro');
};
这里的目标是在用户登录时重新设置应用程序的根目录。知道我做错了什么吗?