百度了一番,下面的代码确实可以实现拖拽功能,但是怎么能获取到拖拽后到table数据呢?现在这样取到的数据还是拖拽以前的顺序
rowDrop() {
const tbody = document.querySelector('.el-table__body-wrapper tbody')
const _this = this
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const currRow = _this.tableData.splice(oldIndex, 1)[0]
_this.tableData.splice(newIndex, 0, currRow)
_this.$nextTick(() => {
console.log('拖拽后', _this.tableData)
})
},
})
},
配置项添加forceFallback:true