【问题标题】:Meteor iron:router transitions流星铁:路由器过渡
【发布时间】:2016-01-07 18:05:28
【问题描述】:

我正在尝试使用 Iron:router 来实现页面之间的转换。我在 css 中定义了动画,现在我需要的就是用 Iron:router 调用它们。由于某种原因,以下代码:

animateContentOut = function() {
    $('#content').removeClass("animated fadeIn");
    return $('footer').addClass("hide");
}

fadeContentIn = function() {
    $('#content').addClass("animated fadeIn");
    return $('footer').removeClass("hide");
}

Router.onBeforeAction(animateContentOut);
Router.onAfterAction(fadeContentIn);

返回异常:

路由调度从未渲染。您是否忘记调用 this.next() 一个 onBeforeAction?

【问题讨论】:

    标签: javascript meteor css-transitions


    【解决方案1】:

    按照 Iron-Router 文档中的说明,现在 onBeforeActiononAfterAction 回调都需要 this.next()https://github.com/iron-meteor/iron-router

    因此,只需将该行添加到您的 fadeContentInanimateContentOut 代码的末尾即可。

    【讨论】:

    • 我更新了我的代码,现在它可以完美运行了。但唯一的问题是它只适用于第一条路线。
    • 您是否也为animateContentOut 做过?我将其添加到我的答案中。
    【解决方案2】:

    如果你有登录尝试这样

    Router.onBeforeAction(function () {
        if (!Meteor.user()) {
          this.render('Login');
        } else { 
          this.next();
         }
    });
    

    【讨论】:

      猜你喜欢
      • 2014-09-03
      • 1970-01-01
      • 2015-08-11
      • 2016-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 2014-09-07
      相关资源
      最近更新 更多