Meteor 流星铁的执行顺序是什么?
我有一些路由器代码:Meteor 流星铁的执行顺序是什么?,meteor,Meteor,我有一些路由器代码: Router.route('/box', { name: 'box', action: function(){ this.layout('appWrapperLoggedInTpl'); this.render('boxCanvasTpl'); }, onAfterAction: function(){ console.log("onAfterAction executed!");
Router.route('/box', {
name: 'box',
action: function(){
this.layout('appWrapperLoggedInTpl');
this.render('boxCanvasTpl');
},
onAfterAction: function(){
console.log("onAfterAction executed!");
renderBoxPage();
}
});
和一个onRendered函数:
Template.boxCanvasTpl.onRendered( function() {
console.log('onRendered executed!');
});
运行此命令时,“onAfterAction executed!”出现在“onRendered executed!”消息之前。我本以为
this.render('boxCanvasTpl')代码>路由器代码的一部分会事先执行,这不是预期的吗?执行顺序是正确的,但是这个.render('boxCanvasTpl')代码>花一些时间将模板插入DOM。您可能需要移动renderBoxPage()将>编码到onRendered函数中