在主干应用程序中获取以前的路由器/url [英] Get previous router/url in backbone application

查看:9
本文介绍了在主干应用程序中获取以前的路由器/url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主干应用程序,我需要知道访问当前路由的路由器.可能吗?

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

例如:-

我从 #/test1 到达 #/current,在另一个例子中,也从 #/test1.

I reach #/current from #/test1 and also in another instance, from #/test1.

那么我可以通过某种方式知道检测以前的路由器命中吗?

So can i know through some way to detect the previous router hit?

我用过:

Backbone.history.fragment

这只会给我当前访问的路线,而不是从哪条路线.

and this only gives me the current route accessed and not from which route.

推荐答案

您可以将历史记录存储在某个数组中,并对上一个/上一个项目进行一些操作.

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

这篇关于在主干应用程序中获取以前的路由器/url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆