【问题标题】:Durandal activating to specific route not workingDurandal 激活到特定路线不起作用
【发布时间】:2015-09-15 21:41:53
【问题描述】:

我有以下几点:

<div class="page-host" data-bind="router: { transition:'entrance' }"></div>

使用标准路由器配置,我调用:

return router.activate('browse');

但是,我每次都会收到“你好”。我需要有条件地选择从 shell 中导航到哪条路线 - 这怎么做?

我的路由配置:

router.map([
                { route: ['', 'hello'], title: 'hello', moduleId: 'hello/hello', nav: true, allowedUsers: ['authenticated', 'unauthenticated'] },

                { route: 'browse', moduleId: 'browse/browse', nav: true, allowedUsers: ['authenticated'] },

                { route: 'resetpassword/:id', moduleId: 'forgot/reset', nav: false, allowedUsers: ['unauthenticated'] }

            ]).buildNavigationModel();

【问题讨论】:

  • 你能澄清一下你需要有条件地选择路线吗?你的意思是说,当用户进入应用程序时,shell 需要根据一些条件有条件地选择初始路由?你能告诉我们你的条件逻辑吗?谢谢。

标签: durandal durandal-2.0


【解决方案1】:

我最终提取了 routes 数组并在调用 router.map 之前对其进行了操作以设置默认路由 - 尽管我会保持打开状态以防有更好的方法。

【讨论】:

    【解决方案2】:

    您可以使用 startRoute 参数指定激活时使用哪个路由,如下所示:

    return router.activate({
        startRoute: "myStartRoute"
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-12
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 2018-05-25
      • 2018-06-25
      • 2014-08-30
      相关资源
      最近更新 更多