【发布时间】:2021-08-22 06:40:01
【问题描述】:
我正在使用 Angular-11。
我有这个代码:
header.component.html:
header.component.ts:
logout($event: MouseEvent){
// tslint:disable-next-line:no-unused-expression
$event.preventDefault();
this.loggedIn = false;
this.token.remove();
this.auth.changeAuthStatus(false);
this.router.navigateByUrl('/login');
this.notify.info("Logout Succesfully", {timeout:2000});
}
我收到了这个错误:
错误 TS2554:预期 1 个参数,但得到 0
它突出显示 logout()。
我该如何解决这个问题?
谢谢
【问题讨论】:
-
您的函数需要一个参数:
logout($event: MouseEvent)。在模板 html 中使用时不传递任何参数。
标签: angular