Meteor 流星';s iron:路由器加载模板未渲染
我有以下代码:Meteor 流星';s iron:路由器加载模板未渲染,meteor,iron-router,Meteor,Iron Router,我有以下代码: Router.configure({ layoutTemplate: 'commonTemplate', loadingTemplate: 'loadingApp' }); Router.route('/configuration', { name:'configuration', template:'configuration', onBeforeAction: function(){ this.
Router.configure({
layoutTemplate: 'commonTemplate',
loadingTemplate: 'loadingApp'
});
Router.route('/configuration', {
name:'configuration',
template:'configuration',
onBeforeAction: function(){
this.layout(null);
if (Session.get('appReady')){
this.next();
} else {
console.log("loading app...");
this.render('loadingApp');
}
}
});
控制台上正确显示“加载应用程序…”。
但是,在此期间(等待会话变量),不会显示加载模板(既不是来自Router.configure,也不是来自this.render)。
此外,当会话变量为true时,配置模板将正确呈现
这是一个iron:router错误还是我做错了什么?您的代码对我有效,可能问题是您的加载模板没有正确显示加载内容。我用包中的加载模板测试了代码,效果很好 您可以从atmospherejs安装软件包sacha:spin并将Iron Router配置为使用加载模板,此软件包易于使用,您必须在需要加载动画的位置使用模板“加载” 1)
meteor add sacha:spin
2) 在路由器文件中:
Router.configure({
loadingTemplate: 'loading'
});
Router.route('/test', {
name: 'test',
template: 'test',
onBeforeAction : function()
{
this.layout(null);
if (Session.get('appReady')){
this.next();
} else {
console.log("loading app...");
this.render('loading');
}
}
}
);
您使用的是哪一版本的Meteor and Iron路由器?