【发布时间】:2015-01-02 14:24:08
【问题描述】:
我在 Meteor JS 应用程序中为我的 Iron-router signOut 路由提供了以下代码。我正在尝试将已弃用的 Router.map 转换为新的 Router.route 语法,但很难让 onBeforeAction 和 onAfterAction 工作。以下代码块的正确 Router.route 语法是什么?
Router.map(function () {
// sign-out the user then redirect them to the home page
this.route('signOut', {
path: '/sign-out',
onBeforeAction: function () {
if (Meteor.userId()) {
Meteor.logout()
}
this.next();
},
onAfterAction: function () {
this.redirect('/');
}
});
});
【问题讨论】:
标签: meteor iron-router