import Sortable from "sortablejs
mounted(){
this.initSort()
}
initSort() {
const el = document.querySelectorAll(
".el-table__body-wrapper > table > tbody"
)[0];
new Sortable(el, {
onEnd: ({ oldIndex, newIndex }) => {
// 监听拖动结束事件
const targetRow = this.tableData.splice(oldIndex, 1)[0];
this.tableData.splice(newIndex, 0, targetRow);
//下面根据自己的业务调用保存接口
},
});
},