【问题标题】:Meteor's iron:router loadingTemplate not renderedMeteor's Iron:路由器加载模板未渲染
【发布时间】:2016-01-16 05:42:48
【问题描述】:

我有以下代码:

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)。 同样,当 session 变量为 true 时,configuration 模板会正确呈现。

这是 iron:router 错误还是我做错了什么?

【问题讨论】:

  • 您使用的是哪个版本的 Meteor 和 Iron 路由器?

标签: meteor iron-router


【解决方案1】:

您的代码对我有用,也许问题是您的加载模板没有正确显示加载内容。我使用 https://atmospherejs.com/sacha/spin 包中的加载模板测试了代码并且工作正常。

你可以从大气js安装包sacha:spin并配置Iron Router使用加载模板,这个包很容易使用,你必须在你想要加载动画的地方使用模板'loading'。

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');
        }
    }
  }
);

【讨论】:

    猜你喜欢
    • 2015-05-24
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 2015-03-14
    • 1970-01-01
    • 2015-12-24
    • 2015-12-30
    • 2015-05-31
    相关资源
    最近更新 更多