虽然在cdkDropList中添加一个Item时,由于数据排序属性,它位于最左边,但我想在cdkDropList中停止自动排列功能。可行吗如果是,那怎么办?
还可以获取这些子项的XY坐标吗?需要一些帮助。
<div cdkDropList [cdkDropListData]="items" cdkDropListDropped)="drop($event)">
<div cdkDrag [cdkDragData]="item" *ngFor="let item of items;">
{{item.name}}
</div>
</div>
答案 0 :(得分:0)
您是否对放置事件做出了任何反应?您应该自己在支持数组中移动项目。
根据the official docs改编的示例:
drop(event: CdkDragDrop<string[]>) {
moveItemInArray(this.items, event.previousIndex, event.currentIndex);
}
您还必须从moveItemInArray
导入@angular/cdk/drag-drop
。