0

如何在 shell.js 中监听视图更改事件?

我想在新视图激活时为标签生成 href

我正在使用 Durandal 2.x

4

1 回答 1

5

您可以尝试订阅 shell.js 中路由器的 activeInstruction observable

define(['plugins/router', 'durandal/app'], function (router, app) {

    router.activeInstruction.subscribe(function (configObject) {
        console.log('activeInstruction', configObject);
    });

. . .

这将为您提供一个配置对象,该对象也将包含有关您正在导航的位置的信息。不确定这是否是最好的方法,或者即使它被设计为以这种方式使用但看看,它可能会有所帮助。

于 2013-11-25T16:24:10.710 回答