完全混淆了流星铁路由器中的this.next() [英] Totally confused about this.next() in Meteor iron-router
本文介绍了完全混淆了流星铁路由器中的this.next()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我升级到Meteor 1.0,安装了最新的铁路由器包,尝试运行我的应用程序并在我的控制台日志中收到了这个不错的警告:
I upgraded to Meteor 1.0, installed the latest iron-router package, tried to run my app and got this nice warning in my console log:
路线调度从未呈现过。你有没有忘记在
和onBeforeAction中调用this.next()?
Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
所以我试图修改我的路线根据新版本。
So I tried to modify my routes according to the new version.
this.route('gamePage', {
path: '/game/:slug/',
onBeforeAction: [function() {
this.subscribe('singlePlayer', this.params.slug).wait();
var singlePlayer = this.data();
if (singlePlayer) {
if (singlePlayer.upgrade) {
this.subscribe('upgrades', this.params.slug).wait();
this.next();
}
this.next();
}
this.next();
}],
data: function() {
return Games.findOne({slug: this.params.slug});
},
waitOn: function() { return [Meteor.subscribe('singleGame', this.params.slug)]}
});
我该如何解决这个问题?
非常感谢任何帮助。
How can I fix this? Any help would be greatly appreciated.
推荐答案
尝试删除所有 .wait()
s并删除onBefore函数周围的数组。
Try removing all the .wait()
s and removing the array around your onBefore function.
使用新API this.next()
替换 .wait()
。
这篇关于完全混淆了流星铁路由器中的this.next()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文