我写过shell.js
define(['plugins/router', 'durandal/app'], function (router, app) {
return {
router: router,
activate: function () {
router.map([
{ route: 'login', title: 'login', moduleId: 'viewmodels/login', nav: true }
]).buildNavigationModel();
return router.activate();
}
};
});
和shell.html
<div>
<nav role="navigation">
<div>
<ul data-bind="foreach: router.navigationModel">
<li data-bind="css: { active: isActive }">
<a data-bind="attr: { href: hash }, text: title"></a>
</li>
</ul>
</div>
</nav>
<div class="page-host" data-bind="router: { transition:'entrance' }"></div>
我的login.js是
define(['require', 'knockout', 'durandal/system', 'durandal/app', 'plugins/router', 'jquery'],
function (require, ko, system, app, router, $) {
var loginVM = function () {
var self = this;
self.username = ko.observable();
self.password = ko.observable();
};
return loginVM;
});
和login.html是
<div id="openModal">
<div>
<h4>Please login to proceed</h4>
<div class="row">
<div>
<label for="Username">Username:</label>
<input type="text" id="Username" data-bind="value: userName, hasFocus: setFocus" />
</div>
</div>
<div>
<div>
<label for="Password">Password:</label>
<input type="password" id="Password" data-bind="value: password">
</div>
</div>
<div>
<button id="login" onclick="Users.login()" type="submit" data-bind="click: login, disable: session.isBusy()">Log in</button>
</div>
<p id="warning" class="warning">Invalid username or password !!!</p>
</div>
我正在尝试从shell打开登录页面。任何人都可以帮我解决这个问题,因为登录页面没有在shell之后加载,我做错了。
答案 0 :(得分:-1)
我弄明白了这个问题。 moduleId的路径:&#39; viewmodels / login&#39;错了所以我把它作为moduleId:&#39; app / viewmodels / login&#39;现在正在加载登录页面。