Closed tangjian1891 closed 1 year ago
The second question: file:src/utils/index.ts /**
请问: 为什么对于index=0的drag-item要单独获取第一个firstChild。直接使用parentElement.children[index]获取元素不可以吗? 或者使用 parentElement.firstElementChild获取Element不可以吗?
调试发现parentElement.firstChild会获取到textNode或commentNode,这样经过dom操作后,好像导致了vue的diff失效。
Hello, thank you for your question. Here is our response:
onUpdate
function, I performed deletion and insertion operations on the dom
element and then used moveArrayElement
. The reason for this is that I needed to delete and insert the dom
element to trigger the animation effect. Simply moving the array element would not trigger the animation effect when updating the page.
file:useDraggable.ts
/**
update function, why do I delete the node and then insert the node, and I find that these two lines of code, when executed, move the dom of sortablejs back, the actual effective code is moveArrayElement function.
So, are these two lines of code useless?