我正在摆弄 VaadinRouter,试图保护路线。下面你可以看到我要保护的组件的 onBeforeEnter 代码:
authenticatedDummy = true;
public onBeforeEnter(
location: RouterLocation,
commands: PreventAndRedirectCommands
): Promise<unknown> | RedirectResult | undefined {
if (this.authenticatedDummy) {
console.log('OnBeforeEnter');
return new Promise(resolve => {
setTimeout(() => {
resolve(commands.redirect('/home'));
}, 2000);
});
}
return undefined;
}
我不明白为什么路由器会路由我,如果authenticatedDummy
是假的。当我阅读代码时,if authenticatedDummy is true, redirect me to '/home'
.
这是阅读它的正确方式还是我忽略了什么?