[英]Click Event is triggered around the actual button
我正在开发离子应用程序。 我有一个离子列表,其中包含离子项目上的单击事件。 当我单击离子列表项时,也会触发单击事件
离子项目触发onclick仅在这里
离子列表红色标记显示了我可以触发事件的位置
<div> <ion-list *ngFor="let y of x"> <p>Date</p> <ion-item *ngFor="let z of y" (click)="click(y.id)"> {{event.title}} </ion-item> </ion-list> </div>
项目之间的细小缝隙是可点击的...为什么以及如何更改它?
解
将event.stopPropagation()添加到click事件。
click(id :string){
event.stopPropagation();
//more code
}
您应该停止event bubbling
以停止单击父元素:您应该为此使用event.stopPropagation()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.