jquery - 为什么我的点击事件只发生一次?
问题描述
我有一个列表元素,其中包含下拉菜单下拉引导 div。默认情况下,在此列表元素上单击(markAllMessagesAsSeenHandle() 方法)时会显示下拉菜单,但除了我想在我的列表元素上有一个单击事件。当我第一次单击列表元素时,页面初始加载后,单击事件正在发生。但在那之后,当我再次单击时,我在控制台和 markAllMessagesAsSeenHandler 中看不到任何内容。这是为什么 ?
<div class="wrapper">
<li class="nav-item dropdown" (click)="markAllMessagesAsSeenHandler()">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<svg role="img" class="dropdown-image">
<image width="24" height="24" xlink:href="assets/img/notification.svg" />
</svg>
<div class="notification-icon">
<span class="" [ngClass]= "(userService.user.unseen_notifications_no != 0) ? 'notification-icon__number-positive' : 'notification-icon__number-negative'">{{ userService.user.unseen_notifications_no }}</span>
</div>
<span class="up-icon">⌃</span>
</a>
<div class="dropdown-menu dropup" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" *ngFor="let message of messages">
<div class="notification">
<div class="notification__message"> {{ message.notification }} </div>
<div class="notification__details">
<button class="notification__details-info redirect-button" (click)="redirectTo(message)">Action</button>
<p class="notification__details-info" data-toggle="tooltip" data-placement="bottom" [title]="message.created_at | date:'medium'">{{ moment(message.created_at).fromNow() }}</p>
</div>
</div>
</a>
<div *ngIf="messages && messages.length == 0" class="zero-notifications">You don't have any notifications</div>
<button *ngIf="messages && messages.length != 0" class="dropdown-menu__get-more primary" (click)="getMoreNotificationsHandler()">Get More</button>
</div>
</li>
</div>
// Method
markAllMessagesAsSeenHandler() {
console.log("test");
}
解决方案
推荐阅读
- java - 有没有其他方法可以用来读取代码中的行以执行 readLine() 的功能?
- python-3.x - 一次将可变数量分配给一堆变量
- c# - 如何更改 C# 中的未知属性?
- python-poetry - 上传到 pypiserver 时出现 409 冲突
- unity3d - 用于创建自定义资产的 AR Foundation 面部网格
- core-data - 编辑后如何将 CoreData 实体中的值显示为状态变量
- internet-explorer - Angular App 的组件未显示在 Internet Explorer 浏览器中。单水疗错误
- laravel - 在使用 PHP Sociallite laravel 后端反应原生应用程序上实现使用谷歌登录
- graphql - 如何将初始变量传递给 createPaginationContainer
- racket - 匹配类型化球拍中的哈希表