iron-router:如何像加载路由后点击刷新一样完全加载路由?

iron-router: How to load a route completely just as when hitting refresh after loading a route?

我的 Meteor 应用程序中有一个登录方法,可以在登录系统后将用户重定向到不同的路径。这是我的方法:

Meteor.loginWithPassword(emailVar, passwordVar, function (err) {
            if (err !== undefined) {
               // error handling code
            } else {
                if (!Roles.userIsInRole(Meteor.userId(), 'active')) {
                    return Router.go('account-deactivated');
                }
                if (Roles.userIsInRole(Meteor.userId(), 'pharmacist')) {
                    return Router.go('pharmacist-dashboard');
                }
                if (Roles.userIsInRole(Meteor.userId(), 'admin')) {
                    return Router.go('admin-dashboard');
                }
            }
        });

虽然此方法按预期工作,但由于 JavaScript 加载问题(例如:app.min.js 等),它对我的​​主题 (AdminLTE) 产生了一些问题。例如,滑动效果在重定向页面上不起作用。但是当我从浏览器重新加载页面时,它开始按预期工作。

我知道这是一个需要解决的单独问题。但是,如果有一种方法可以使用 iron-router 在 Meteor 中完全重新加载 link,那将会很有帮助。特别是当页面被转移到一个完全不同的用户环境时,其中使用了一组新的 JavaScript 和 CSS。

我查看了 iron-router 的用户文档,但修复没有提供解决方案。

尝试使用 window.location.href 重定向。

使用 Router.go 只是加载您要 link 前往的路线的模板,而使用 window.location.href 加载 url 就好像它是 link 你刚刚点击了(实际刷新)。

不过您需要使用实际的 url,而不是 'route name'。

window.location.href = "http://yourapp.com/route/here";