我在弹出模式下使用 PrimeNG 的 p-menu 组件 ([popup]="true"),并且遇到了不良行为:菜单中的第一项被自动选择并变成灰色`,
<p-menu #menu [popup]="true" [model]="items">
<ng-template pTemplate="item" let-item>
<a class="p-menuitem-link flex justify-content-between align-items-center"
*ngIf="item.icon=='delete', else other">
<div class="tw-flex tw-items-center tw-space-x-2" [ngStyle]="{'color': item.icon === 'delete' ? 'red' : 'inherit'}" (click)="confirm1($event)">
<span class="material-icons-round">{{ item.icon }}</span>
<span>{{ item.label }}</span>
</div>
</a>
<ng-template #other>
<a class="p-menuitem-link flex justify-content-between align-items-center">
<div class="tw-flex tw-items-center tw-space-x-2">
<span class="material-icons-round">{{ item.icon }}</span>
<span>{{ item.label }}</span>
</div>
</a>
</ng-template>
</ng-template>
</p-menu>
我尝试了多种解决方案,包括在菜单开头添加隐藏项以及修改CSS,但都没有奏效。有谁知道如何在弹出模式下禁用 p 菜单中第一项的自动选择?
当然,您可以通过以下方式在 Stack Overflow 帖子中用英语回答这些问题:
你尝试了什么?
我在弹出模式下使用 PrimeNG 的 p 菜单组件 ([popup]="true")。我尝试了多种解决方案来禁用菜单中第一项的自动选择,包括在菜单开头添加隐藏项以及修改 CSS。
要禁用 PrimeNG 弹出菜单中第一项的自动选择,您可以探索以下区域:
• PrimeNG p 菜单配置 • CSS 定制