在网上找了一段代码实现了表格的行拖拽
sortlist() {
const tbody = document.querySelector('.el-table__body-wrapper tbody')
const _this = this
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const currRow = _this.newsList.splice(oldIndex, 1)[0]
_this.newsList.splice(newIndex, 0, currRow)
}
})
},
mounted() {
this.sortlist()
},
拖拽后变成了
有什么方法能让第一列的id保持不变吗 只让后面的内容改变 id是我scope.$index生成的
求解
拖动完成遍历数组更新 id