1、定义好拖拽元素 ref标识,以及 row-key="id" (row-key拖拽标识,拖拽后数据不会乱, id为tableDataNew数据对象id)
2、下载cnpm install sortablejs --save 插件,并引入 import Sortable from 'sortablejs'
3、nextTixk触发
this.$nextTick(() => { this.rowDrop(); }) 4、行拖拽 rowDrop() { const tbody = this.$refs.manufacturing.$el.querySelector( ".el-table__body-wrapper > table > tbody" ); const _this = this; Sortable.create(tbody, { onEnd({ newIndex, oldIndex }) { const currRow = _this.tableDataNew.splice(oldIndex, 1)[0]; _this.tableDataNew.splice(newIndex, 0, currRow); }, }); }, 标签:el,tableDataNew,const,tbody,拖拽,vue2,element,id From: https://www.cnblogs.com/zj6666/p/17122491.html