我试图瞄准一个事件,但我得到错误,我所尝试的是
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 as any来解决这个错误,但是我想纠正这个错误,有什么解决方案吗?
1条答案
按热度按时间qmelpv7a1#
检查您的事件类型是否从其他地方导入?