如何找到导致非自愿路由的代码位? (在遗留网站中)
How to find the bit of code that causes involuntary routing? (in a legacy website)
请帮助我,我正在重新使用基于 AngularJS 的旧网站,但我一直遇到由未知代码引起的意外路由事件。
当我按下网站上的各种元素时 none 其中有明显的事件处理程序
使用这样的代码,路由会按预期指向 "page-not-found" 页面。
我已经在“$location”和“$route”的所有引用处设置了断点。我已经在代码中查找了所有 "href" 属性
而且我没有发现任何可疑的东西。
当我在“$routeChangeStart”挂钩中放置一个断点时,如下所示
$rootScope.$on('$routeChangeStart', function (event, next, current) {
debugger;
//.....
}
我得到了以下对象:
next = {
params: {}
pathParams: {}
}
(没有“$$route”)
event = {
currentScope: m {$id: 2, $$childTail: m, $$childHead: m, $$prevSibling: null,
$$nextSibling: null, …}
defaultPrevented: false
name: "$routeChangeStart"
preventDefault: ƒ ()
targetScope: m {$id: 2, $$childTail: m, $$childHead: m, $$prevSibling: null,
$$nextSibling: null, …}
}
(targetScope==currentScope) 为真
该项目还使用了Kendo和JQuery
我知道我不能期待任何具体的答案,但欢迎任何建议。
我应该看哪里?
我必须做的是检查调试器中的调用堆栈停在
中的断点处
$rootScope.$on('$routeChangeStart' ...
pathParams 为空,因为路由无效。
请帮助我,我正在重新使用基于 AngularJS 的旧网站,但我一直遇到由未知代码引起的意外路由事件。
当我按下网站上的各种元素时 none 其中有明显的事件处理程序 使用这样的代码,路由会按预期指向 "page-not-found" 页面。
我已经在“$location”和“$route”的所有引用处设置了断点。我已经在代码中查找了所有 "href" 属性 而且我没有发现任何可疑的东西。
当我在“$routeChangeStart”挂钩中放置一个断点时,如下所示
$rootScope.$on('$routeChangeStart', function (event, next, current) {
debugger;
//.....
}
我得到了以下对象:
next = {
params: {}
pathParams: {}
}
(没有“$$route”)
event = {
currentScope: m {$id: 2, $$childTail: m, $$childHead: m, $$prevSibling: null,
$$nextSibling: null, …}
defaultPrevented: false
name: "$routeChangeStart"
preventDefault: ƒ ()
targetScope: m {$id: 2, $$childTail: m, $$childHead: m, $$prevSibling: null,
$$nextSibling: null, …}
}
(targetScope==currentScope) 为真
该项目还使用了Kendo和JQuery
我知道我不能期待任何具体的答案,但欢迎任何建议。
我应该看哪里?
我必须做的是检查调试器中的调用堆栈停在
中的断点处$rootScope.$on('$routeChangeStart' ...
pathParams 为空,因为路由无效。