<template>
<Table :columns="col" row-key="id" :data="tableData"></Table>
</template>
<script>
import Sortable from "sortablejs";
export default {
props: {
tableData: Array,
col: Array
},
mounted() {
this.columnDrop();
},
methods: {
// 列拖拽
columnDrop() {
const wrapperTr = document.querySelector(".ivu-table-header tr");
Sortable.create(wrapperTr, {
animation: 150,
delay: 0,
onEnd: evt => {
const oldItem = this.col[evt.oldIndex];
this.col.splice(evt.oldIndex, 1);
this.col.splice(evt.newIndex, 0, oldItem);
}
});
}
}
};
</script>
目前效果是可以进行拖拽,但是拖拽之后会出现显示错误,数据对应不上,但是打印出的数据是正确的,请问一下这种情况下如何解决?
看起来像是动态响应的问题,最后一句改成这样试试看?