杜兰达尔默认路线有效,其他什么都没有
Durandal default route works, nothing else
我一直在绞尽脑汁,在互联网上找不到这个问题的答案。使用Hot towelette设置网站,将其升级到durandal 2.0和所有相关软件包。遵循Durandal网站上从1.0升级到2.0的指南,除了路线外,其他一切都正常工作。默认路由正常工作,网站会按预期加载默认页面。然而,点击页面顶部的导航,url会发生变化,但什么也没发生。url更改为http://host/#view.我看到散列后缺少斜杠,并将散列添加到路由中以修复该问题,但仍然没有更改视图。我试过很多不同的样品等,但没有发现问题所在。
main.js
require.config({
paths: {
"text": "../Scripts/text",
"durandal": "../Scripts/durandal",
"plugins": "../Scripts/durandal/plugins",
"transitions": "../Scripts/durandal/transitions",
}
});
define('jquery', [], function() { return jQuery; });
define('knockout', [], function () { return ko; });
define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'plugins/router', 'services/logger'],
function (system, app, viewLocator, router, logger) {
app.title = "Remedy Approvals";
app.configurePlugins({
router: true
})
// Enable debug message to show in the console
system.debug(true);
app.start().then(function () {
toastr.options.positionClass = 'toast-bottom-right';
toastr.options.backgroundpositionClass = 'toast-bottom-right';
router.handleInvalidRoute = function (route, params) {
logger.logError('No Route Found', route, 'main', true);
};
// When finding a viewmodel module, replace the viewmodel string
// with view to find it partner view.
//router.makeRelative({ moduleId: 'viewmodels' });
viewLocator.useConvention();
// Adapt to touch devices
//app.adaptToDevice();
//Show the app by setting the root view model for our application.
app.setRoot('viewmodels/shell', 'entrance');
});
});
shell.js:
define(['durandal/system', 'plugins/router', 'services/logger'],
function (system, router, logger) {
var shell = {
router: router,
activate: activate
};
return shell;
function activate() {
var routes = [
{ route: ['approvals',''], moduleId: 'approvals', title: 'My Approvals', nav: true, hash: '#/approvals' },
{ route: 'alternate', moduleId: 'alternate', title: 'Alternate Approvals', nav: true, hash: '#/alternate' }
];
return router.makeRelative({ moduleId: 'viewmodels' })
.map(routes)
.buildNavigationModel()
.mapUnknownRoutes('approvals', 'not-found')
.activate();
}
// function log(msg, data, showToast) {
// logger.log(msg, data, system.getModuleId(shell), showToast);
// }
}
)
shell.html
<div>
<header>
<!--ko compose: {view: 'nav'} --><!--/ko-->
</header>
<section id="content" class="main container-fluid">
<!--ko compose: {model: router.activeItem,
afterCompose: router.afterCompose,
transition: 'entrance'} -->
<!--/ko-->
</section>
<footer>
<!--ko compose: {view: 'footer'} --><!--/ko-->
</footer>
</div>
nav.html
<div>
<ul class="nav nav-pills" data-bind="foreach: router.navigationModel">
<li role="presentation" data-bind="css: {active: isActive}"><a data-bind="attr: {href: hash}, html: title"></a></li>
</ul>
<label class="pull-right">username</label>
</div>
您在路由器的activeItem属性上使用compose绑定。我不知道这是否是"错误的",但我正在使用我的"路由器"绑定:
<div class="container page-host" data-bind="router"></div>
摘录自http://durandaljs.com/get-started.html:
视图底部是一个特殊的路由器绑定,用于连接到模块中的路由器。这是一个占位符,其中将显示当前"页面"。transition属性表示无论何时页面更改,Durandal都应该使用"入口"过渡动画。
相关文章:
- 是什么让一个“;Uncaught RangeError:超过了最大调用堆栈大小“;错误(Chrome,在其他浏览器中显示
- 什么's导致了512字节的限制-openkeyval或其他什么
- 杜兰达尔默认路线有效,其他什么都没有
- javascript或缓存错误?或者其他什么
- 在IE8和其他带有javascript的浏览器中获取正文类的标准解决方案是什么
- 如果React.js是V,那么在MVC中,其他字母是什么
- document.write和document.innerHTML以及其他javascript问题之间有什么区别
- 如何上传文件不使用多部分编码?(可能使用八位字节或其他什么)
- @internal react 代码中的 JavaScript 文档标签,是 jsdoc、闭包还是其他什么
- 如何匹配其他一切,但不管它是什么's与regex匹配
- Javascript 我应该使用什么其他技巧来代替导出符号
- javascript:将浮点数四舍五入到最接近的 .25(或其他什么..)
- 在我的测试脚本中,我运行了 if 语句,但我从未运行过其他语句?我做错了什么
- 什么是原型?构造函数或其他对象
- 在默认情况下将可枚举设置为 false 的 JS 中创建对象属性的其他方法是什么
- Request.text()(以及从 Body 实现的其他函数)实际上做了什么
- Javascript:当Javascript在IE中工作而在Firefox或其他浏览器中不工作时,有什么不同的条件
- 即时角度服务-我还有什么其他方式可以重写它
- 如何检测客户端´s的计算机语言/或其他什么,以便自动更改网站中的语言
- 在JavaScript中,换行符实际上并不是在创建新行,有没有其他选择,或者我做错了什么