0

I have a list of objects that can each have their own list of children down to any level, and they can be dragged anywhere within the list of object trees. The data is stored in Vuex and I have the draggables bound to a computed property with a getter and setter (the setter splices in/overwrites the list).

The issue I'm having is when I drag an item anywhere below the first level of the same tree, it disappears, UNLESS I am reordering it amongst siblings on the same level. It seems to work fine to drag it anywhere else so long as it's not within the same tree. This makes me suspect it's a mismatch in timing as the events are emitted up the tree structure, but at the same time it's always removed and never appears in the new location whether it's dragged down or up further in the tree.

我想知道这是否是因为当嵌套对象更改时在树上发出更新事件,而不是更新和提交更新到顶层的 Vuex 存储。我在设置器中正确记录了更改,但它似乎在数据后立即被覆盖并从 dom 中消失。

这是其他人遇到的吗?有人可以解释操作顺序,也许我有一个删除更新覆盖添加更新的问题?

4

1 回答 1

0

我最终通过检查列表是否在触发设置器时减小了大小并将状态的克隆和更新延迟到添加的元素完成更新后才解决了这个问题。感觉就像一个彻底的黑客,所以如果有人想在使用 vuedraggable 更新商店中的嵌套组件时如何避免这种情况,我希望你的见解。

于 2020-08-04T17:52:41.847 回答