【问题标题】:Iron Router changes router conditionIron Router 更改路由器状态
【发布时间】:2016-02-26 18:59:24
【问题描述】:

当路由器仅从“主页”更改为“关于页面”或任何其他页面,但从主页更改时,我想 console.log。

我无法想出任何逻辑,所以没有尝试任何东西。

【问题讨论】:

    标签: meteor iron-router


    【解决方案1】:

    试试这样的

    Router.route('/', {
        name : 'home',
        template : 'home',
        title: 'Home'
    });
    
    Router.route('/about', {
        name : 'about',
        template : 'about',
        title: 'About'
    });
    
    Router.onStop(function(){
         Session.set("previousPath",Router.current().route.getName());
    });
    
    Router.onBeforeAction(function(){
        if(Session.get("previousPath")=="home"){
            console.log('something')
        }
        this.next()     
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-14
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多