gpt4 book ai didi

meteor v 1.0 和铁 :Router

转载 作者:行者123 更新时间:2023-12-03 00:10:08 24 4
gpt4 key购买 nike

自从将 Meteor 升级到版本 1.0 后,还有其他人从 Iron-Router 收到以下错误吗?

如果您知道如何解决此问题,请在此处发帖。

Route dispatch never rendered. Did you forget to call this.next() in an 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};
}
}
});
});

最佳答案

最新版本的 Iron Router 中存在非向后兼容的更改。迁移指南说:

onRun and onBeforeAction hooks now require you to call this.next(), and no longer take a pause() argument. So the default behaviour is reversed. For example, if you had:

Router.onBeforeAction(function(pause) {
if (! Meteor.userId()) {
this.render('login');
pause();
}
});

You'll need to update it to

Router.onBeforeAction(function() {
if (! Meteor.userId()) {
this.render('login');
} else {
this.next();
}
});
<小时/>

More information

在您的情况下,按书本的修复方法是在 onBeforeAction 末尾添加 this.next() 。但是,您应该使用 waitOn:

waitOn: function () {
return Meteor.subscribe("userData");
}

这样,您就可以设置一个 loadingTemplate,该模板将在加载 userData 订阅时显示。

关于 meteor v 1.0 和铁 :Router,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26629835/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com