我有一个主干应用程序,我需要知道访问当前路由的路由器。可能吗?
例如:-
我从 #/test1
到达 #/current
,在另一个实例中,从 #/test1
到达。
那么我可以通过某种方式知道检测之前的路由器命中吗?
我用过:
Backbone.history.fragment
这只给我当前访问的路线,而不是从哪条路线。
最佳答案
您可以将您的历史存储在某个数组中,并对上一个/上一个项目进行一些操作。
var history = [];
this.listenTo(this, 'route', function (name, args) {
history.push({
name : name,
args : args,
fragment : Backbone.history.fragment
});
console.log(history);
});
关于javascript - 在主干应用程序中获取以前的路由器/url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18735111/