Vue Draggable add event picking up incorrect item
我正在使用Vue.Draggable:https://github.com/SortableJS/Vue.Draggable
提琴:https://jsfiddle.net/o5pcLhhj/
我有两个列表设置,并且可以在它们之间拖动。我已将onAdd事件添加到第二个列表,以便可以检测到何时将某些内容添加到该列表:
1 2 3 | onAdd: function(evt) { console.log(evt.item); } |
现在,如果我将" John"或" Joao"拖到第二个列表,则说明该事件未正确拾取所拖入的项目。似乎已被一个索引关闭。如果将" Jean"拖入其中,它将正确地拾取该项目。
我在这里做错了什么!!
提琴:https://jsfiddle.net/o5pcLhhj/
提前谢谢!!
使用其他密钥。索引不是很好的键。
1 2 3 | {{element.name}} ... {{element.name}} |
更新的小提琴。
这里我使用的是名称,但理想的情况是每个列表项的某些唯一
1 2 3 4 5 | list: [ { name:"John", id: 1 }, { name:"Joao", id: 2 }, { name:"Jean", id: 3 } }], |
etc和
1 | {{element.name}} |