自从将Meteor升级到1.0版以来,是否有其他人从Iron-Router收到以下错误?
如果您知道如何解决此问题,请在此处发帖。
路线调度从未呈现过。您忘记在
this.next()
中致电onBeforeAction
了吗?
Router.map(function () {
Router.route('profileShow', {
waitOn: function () {
if (Meteor.user()) {
Meteor.subscribe('userData');
} else {
this.next();
}
},
data: function () {
if (Meteor.user()) {
return {profile: Meteor.user().profile};
}
}
});
});
答案 0 :(得分:29)
最新版本的Iron Router存在非向后兼容的更改。迁移指南说:
onRun
和onBeforeAction
挂钩现在要求您调用this.next()
,而不再使用pause()
参数。因此默认行为是相反的。例如,如果您有:
Router.onBeforeAction(function(pause) {
if (! Meteor.userId()) {
this.render('login');
pause();
}
});
您需要将其更新为
Router.onBeforeAction(function() {
if (! Meteor.userId()) {
this.render('login');
} else {
this.next();
}
});
在您的情况下,通过书籍修复将在this.next()
的末尾添加onBeforeAction
。但是,您应该使用waitOn
:
waitOn: function () {
return Meteor.subscribe("userData");
}
这样,您可以设置loadingTemplate
,这会在加载userData
订阅时显示。