import Sortable from 'sortablejs'
// 要侦听拖拽响应的DOM对象
const tbody = document.querySelector('.draggable-table .el-table__body-wrapper tbody')
const _this = this
Sortable.create(tbody, {
// 结束拖拽后的回调函数
onEnd({ newIndex, oldIndex }) {
const currentRow = _this.tableData.splice(oldIndex, 1)[0]
_this.tableData.splice(newIndex, 0, currentRow)
}
})
<el-table
ref="multipleTable"
:data="tableData"
style="width: 100%"
row-key="name"
border
size="mini"
@row-click="rowSelect"
@select="handleSelect"
@selection-change="handleSelectionChange"
:max-height="computedHeight"
:row-class-name="tableRowClassName"
class="draggable-table"
></el-table>
el-table拖拽排序
最新推荐文章于 2025-03-28 13:35:03 发布