click(){
this.$nextTick(() => {
this.setSort(); //表格拖拽
});
}
setSort() {
if (this.$refs.questionMultipleTable != undefined) {
const el = this.$refs.questionMultipleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0];
this.sortable = Sortable.create(el, {
ghostClass: 'sortable-ghost',
setData: function (dataTransfer) {
dataTransfer.setData('Text', '');
},
onEnd: (evt) => {
const targetRow = this.questionTableData.splice(evt.oldIndex, 1)[0];
this.questionTableData.splice(evt.newIndex, 0, targetRow);
}
});
}
},
el-table加上ref:
<el-table
border
ref="questionMultipleTable"
:data="questionTableData"
tooltip-effect="dark"
style="width: 100%"
height="350"
highlight-current-row
row-key="questId"
@selection-change="handleSelectPaperChange"
>xxxx</el-table>