Routing 儿童路由器durandal 2 HTML启动工具包
我试图在durandal 2 starterkit中创建子路由,如中所示,但没有成功 我想有点像 因此,在我的应用程序中,我在viewmodel中有一个shell文件viewmodel/shell.jsRouting 儿童路由器durandal 2 HTML启动工具包,routing,durandal-2.0,Routing,Durandal 2.0,我试图在durandal 2 starterkit中创建子路由,如中所示,但没有成功 我想有点像 因此,在我的应用程序中,我在viewmodel中有一个shell文件viewmodel/shell.js { route: 'blog*details', title:'Blog', moduleId: 'blog/index', nav: 2, hash: '#blog' }, 及 应用内/博客/ 我有 index.js index.js default/index
{ route: 'blog*details', title:'Blog', moduleId: 'blog/index', nav: 2, hash: '#blog' },
及
应用内/博客/
我有
index.js
index.js
default/index.js
default/index.html
为什么它不起作用我做错了什么
thx
编辑:
这就是我的shell.js的样子
define(['plugins/router', 'durandal/app'], function (router, app) {
return {
router: router,
attached : attached,
search: function() {
//It's really easy to show a message box.
//You can add custom options too. Also, it returns a promise for the user's response.
app.showMessage('Search not yet implemented...');
},
activate: function () {
router.map([
{ route: '', title:'Home', moduleId: 'viewmodels/home', nav: 1 },
{ route: 'blog*route', title:'Blog', moduleId: 'blog/index', nav: 2, hash: '#blog' }
]).buildNavigationModel();
return router.activate();
},
footerLinks : [
...
]
};
function attached() {
}//=======attached end
});
一种方法是,您需要创建一个子路由器来处理splat路由
blog*详细信息
在index.js文件(so app/blog/index.js)中,您需要像这样创建子路由器
define(['plugins/router'],function(router){
var childRouter = router.createChildRouter().makeRelative({ moduleId: 'blog', fromParent: true})
.map([
...insert routes here...
]).buildNavigationModel();
return {
router: childRouter
};
});
从那时起,您可以创建所有的路由,如blog/post1、blog/post2等。请查看的ko文件夹中的示例,然后再显示一些代码。我们似乎不知道你在哪里创建你的孩子路由器等@这里你被逐出教会