我正在尝试在另一个放置区域内创建一个放置区域,并且我希望能够在两个放置区域中放置。为了实现这一点,我尝试使用“cdkDropListConnectedTo”作为所有放置区域的 id,但由于某种原因未检测到子放置区域。
stackblitz 链接: https ://stackblitz.com/edit/drag-drop-inside-another-container?file=app%2Fcdk-drag-drop-connected-sorting-example.html
我正在尝试在另一个放置区域内创建一个放置区域,并且我希望能够在两个放置区域中放置。为了实现这一点,我尝试使用“cdkDropListConnectedTo”作为所有放置区域的 id,但由于某种原因未检测到子放置区域。
stackblitz 链接: https ://stackblitz.com/edit/drag-drop-inside-another-container?file=app%2Fcdk-drag-drop-connected-sorting-example.html
如我所见,未检测到子区域,因为嵌套的 DOM 元素不允许他触发事件。
你能像这样改变你的最后一个元素:
<div class="example-container">
<h2>Done</h2>
<div
cdkDropList
#doneList="cdkDropList"
[cdkDropListData]="done"
[cdkDropListConnectedTo]="todoList"
class="example-list"
(cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of done" cdkDrag>{{item}}</div>
</div>
<hello class="example-box" id='child1' [todoList]='todoList'>{{done}}</hello>
</div>