Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 流星铁的执行顺序是什么?_Meteor - Fatal编程技术网

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函数中