Get previous router/url in backbone application

前端 未结 1 760
深忆病人
深忆病人 2021-01-11 16:51

I have a backbone application and i would require to know the router from which the current route is accessed. Is it possible?

For eg :-

I reach #/curr

相关标签:
1条回答
  • 2021-01-11 17:14

    You can store your history in some array and do some manipulation with last/previous items.

    var history = [];
    this.listenTo(this, 'route', function (name, args) {
      history.push({
        name : name,
        args : args,
        fragment : Backbone.history.fragment
      });
      console.log(history);
    });
    
    0 讨论(0)
提交回复
热议问题