Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Angular CDK 拖放(Material UI),我想在 CdkDragMove 事件对象中获取被拖动项目的当前索引。谁能指导我?
如果您*ngFor用于迭代列表,则可以使用上下文index变量。NgFor
*ngFor
index
NgFor
<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)"> <div class="example-box" *ngFor="let movie of movies; let i = index" (cdkDragMoved)="move($event, i)" cdkDrag>{{movie}}</div> </div>