sortablejs
import Sortable from 'sortablejs'
Sortable.create(document.querySelector('.box'), {
group: {
put: false,
pull: false,
},
sort: true,
animation: 100,
handle: '.dragIcon',
ghostClass: 'sortable-ghost',
onEnd: async (e: { newIndex: number; oldIndex: number }) => {
if (e.newIndex !== e.oldIndex) {
let newArray = deepClone(list.value)
const movedItem = newArray.splice(e.oldIndex, 1)
newArray.splice(e.newIndex, 0, movedItem[0])
list.value = []
await nextTick()
list.value = newArray
}
},
})