【发布时间】:2013-05-16 16:02:27
【问题描述】:
我有 Durandal 的小型 SPA 测试应用程序。
我也有非常有线的问题。
首先,我的文件夹结构是:
应用
--durandal
--viewmodels
----user.js
--views
----user.html
--main.js
当结构是这样时,一切都很好。但是如果我创建像
这样的结构
应用程序
--durandal
--_用户
----视图模型
------user.js
----浏览量
------user.html
我收到类似 localhost/App/_users/viewmodels/users.html 404 Not Found 的错误。这发生在 user.js 被 require.js 加载之后。
我的 main.js 看起来像
require.config({
paths: { "text": "../durandal/amd/text" }
});
define(function (require) {
var system = require('../durandal/system'),
app = require('../durandal/app'),
router = require('../durandal/plugins/router'),
viewLocator = require('../durandal/viewLocator'),
logger = require('../logger');
system.debug(true);
app.start().then(function () {
// route will use conventions for modules
// assuming viewmodels/views folder structure
router.useConvention();
// When finding a module, replace the viewmodel string
// with view to find it partner view.
// [viewmodel]s/sessions --> [view]s/sessions.html
// Otherwise you can pass paths for modules, views, partials
// Defaults to viewmodels/views/views.
viewLocator.useConvention();
app.setRoot('viewmodels/shell');
// override bad route behavior to write to
// console log and show error toast
router.handleInvalidRoute = function (route, params) {
logger.logError('No route found', route, 'main', true);
};
});
});
我认为这个问题与 router.useConvention();或使用 viewLocator.useConvention();但简单找不到这种行为的任何原因。
任何帮助、建议、想法如何解决这个问题?
谢谢
【问题讨论】: