elementUi实现table表格拖拽效果

第一步需要安装一下sortable的依赖
npm i -S vuedraggable
使用:

import Sortable from 'sortablejs';

接下来是方法调用

  drag() {
        const el = document.querySelectorAll('.el-table__body-wrapper > table > tbody')[0];
        Sortable.create(el, {
            disabled: !this.enableDrag,
            ghostClass: 'sortable-ghost',
            setData: function(dataTransfer) {
                dataTransfer.setData('Text', '');
            },
            onEnd: (evt) => {
 				
            }
        });
    },

猜你喜欢

转载自blog.csdn.net/qq_38698753/article/details/102659926