Durandal路由器未激活

Durandal router not activated

本文关键字:激活 路由器 Durandal      更新时间:2023-09-26

我有一个消息框在我的Durandal应用程序,无论你点击否或是你被发送到另一个页面。我想在路由器上这样做,但页面没有切换。

我可以看到代码正在执行这行,但什么也没发生!

define(function(require) {
var app = require('durandal/app'),
    system = require('durandal/system'),
    router = require('durandal/plugins/router');
return {
    router: router,
    displayName: 'SometingApp Startpage',
    activate: function() {
        system.log("Application started!");
    },
    createEstimate: function() {
        app.showMessage('Do you want to create a new something?', 'New something', ['Yes', 'No']).then(function(result) {
            if (result == "Yes") {
                return router.activate('otherpage');
            }
        });
    }
};

});

用户单击绑定到createEstimate的按钮!

希望有人能帮忙!

我认为你需要做的是调用router.navigateTo('#/yourUrl')。

如果我理解正确的文档,路由器。Activate只能调用一次,通常在shell激活时调用。

在文档

中列出了viewModel导航可用的路由函数

http://durandaljs.com/documentation/Router/