Dragula在Vue中拖拽后数据没更新怎么办?
我在用 dragula 做一个任务看板,拖完卡片后 DOM 看起来移过去了,但 Vue 里的数组顺序根本没变,导致保存时还是原来的数据。我试过在 drake.on(‘drop’) 里手动 splice,但总对不上索引,有没有人遇到过类似问题?
<template>
<div ref="container">
<div v-for="(item, i) in tasks" :key="item.id" class="task-card">
{{ item.text }}
</div>
</div>
</template>
<script>
import dragula from 'dragula'
export default {
data() { return { tasks: [{ id: 1, text: 'A' }, { id: 2, text: 'B' }] } },
mounted() {
dragula([this.$refs.container])
}
}
</script>
暂无解答