我有拖放问题,因为我的句柄将来会创建:
drawCharts(tableLetters) {
let countryCharts = '';
for (let i = 0; i < tableLetters.length; i++) {
countryCharts += `
<div class ="dropzone">
<div class="countryChart" draggable="true"><span class="letters">${tableLetters[i]}</div>
</div>
`
}
this.charts.innerHTML = countryCharts;
this.deleteEmptySquare();
}
我尝试将句柄设置为父级,但这样做有误。我想为孩子设置活动,而不是为父母设置活动。我尝试关闭父母的反应,但我不能。
drag() {
if (event.target.classList.contains('countryCharts') || event.target.classList.contains('dropzone') || event.target.classList.contains('letters')) {
return false;
}
}
dragStart() {
this.dragged = event.target;
if (this.dragged.classList.contains('countryCharts') || this.dragged.classList.contains('dropzone') || this.dragged.classList.contains('letters')) {
return false;
}
}
PS。 DRY现在并不重要。