【问题标题】:How to set a Splat route as Default route Durandal 2.0如何将 Splat 路线设置为默认路线 Durandal 2.0
【发布时间】:2013-11-13 05:31:16
【问题描述】:

我的默认路由有子视图,我可以在 Durandal 2.0 中将 Splat 路由设置为默认路由吗? ..

define(['plugins/router'], function (router) {
return {
    router: router,
    activate: function () {
        return router.map([                
            { route: 'knockout-samples*details',    moduleId: 'ko/index',title: 'Knockout Samples',  nav: true, hash: '#knockout-samples' }
        ]).buildNavigationModel()              
          .activate();
    }
};

});

【问题讨论】:

    标签: durandal durandal-2.0 durandal-navigation


    【解决方案1】:

    如果我理解正确,那么是的 - 您可以将 splat 作为您的默认路线。你会在你的 root shell 中做这样的事情:

    router.map({
        moduleId: "child/shell",
        route: "*details"
    });
    

    然后在您孩子的视图模型中:

    var childRouter = rootRouter
        .createChildRouter()
        .makeRelative({ moduleId: "child" });
    
    // Uses "child/defaultPage" as the view model, and "#/" as the route
    childRouter.map({
        moduleId: "defaultPage",
        route: ""
    });
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      • 2019-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多