解决办法:
mounted() {
// 解决Sortable.create在火狐浏览器上会打开新窗口
document.body.ondrop= function (event) {
event.preventDefault();
event.stopPropagation();
}
}
再table复制后,调用下面方法 this.rowDrop()
实现表格拖拽
// 用鼠标动态拖拽排序表格行
rowDrop() {
let tbody = undefined
tbody = document.querySelector(
'#data-element-tbody .el-table__body-wrapper tbody'
)
const that = this
Sortable.create(tbody, {
onEnd({ newIndex, oldIndex }) {
const currRow = that.dataElementList.splice(oldIndex, 1)[0]
that.dataElementList.splice(newIndex, 0, currRow)
}
})
},