【发布时间】:2014-08-12 20:46:31
【问题描述】:
我正在尝试使用 durandal 路由器,但我的控制台上出现以下 2 个错误:
未捕获的错误:脚本错误:durandal/router
当然还有这个: 加载资源失败:服务器响应状态为 404(未找到)
我知道这是非常不言自明的,但我在代码或文件结构上没有发现任何错误。
requirejs.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', 'durandal/plugins/router', 'services/logger'], function (system, app, viewLocator, router, logger) {
app.title = 'My App';
//specify which plugins to install and their configuration
app.configurePlugins({
router: true,
dialog: true,
widget: {
kinds: ['expander']
}
});
system.debug(true);
app.start().then(function () {
router.useConvention();
viewLocator.useConvention();
app.setRoot('viewmodels/shell');
router.handleInvalidRoute = function (route, params) {
logger.logError('No route found', route, 'main', true);
};
});
});
shell.js
define(['durandal/system', 'services/logger', 'durandal/plugins/router','config'],
function(system,logger, router, config) {
var shell ={
activate: activate,
router: router
};
return shell;
function activate(){
logger.log('CodeCamper Jumpstart Loaded!',
null,
system.getModuleId(shell),
true)
router.map(config.routes);
return router.activate(config.startModule);
}
}
);
vs 结构
【问题讨论】:
-
如果我检查开发者工具,router.js 已加载! screencast.com/t/zESs1W2Nj
标签: javascript durandal durandal-2.0