我试图瞄准一个事件,但我得到错误,我所尝试的是
public gotoPage(event: Event): void {
const gettest = (event.target as HTMLElement)?.getAttribute('href');
if (href) {
const testModule = "value1"
if (ssoModule) {
event.preventDefault();
}
}
}
HTML:
<ion-card-content>
<ion-item class="no-padding" (click)="gotoPage($event)">
<div>
{{test}}
</div>
</ion-item>
</ion-card-content>
但是我得到的错误是
Property 'target' does not exist on type 'Event_2'.
Property 'target' does not exist on type 'RouterEvent'.
Property 'preventDefault' does not exist on type 'Event_2'.
Property 'preventDefault' does not exist on type 'RouterEvent'.
现在我使用type作为any来解决这个错误但是我想纠正这个错误,有解决方案吗?
检查您的事件类型是否从其他地方导入?