http://www.sortablejs.com/index.html
npm install sortablejs --save //下载
代码实现
<template>
<div class="table_count">
<el-table
:data="tableData"
border
id="table_count"
stripe
style="width: 100%">
<el-table-column
prop="date"
label="日期"
align="center"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
align="center"
width="180">
</el-table-column>
<el-table-column
prop="address"
align="center"
label="地址">
</el-table-column>
<el-table-column label="操作" align="center">
<template>
<i class="el-icon-rank handle"></i>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import Sortable from 'sortablejs'
export default {
name: "Tab_index",
data() {
return {
oldList: [],
tableData: [{
date: '2023-05-02',
name: 'wang1',
address: '上海市'
}, {
date: '2023-05-04',
name: 'wang2‘,
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2023-05-01',
name: 'wang3‘,
address: '上海市'
}, {
date: '2024-05-03',
name: 'wang4‘,
address: '上海市'
}]
}
},
mounted() {
this.rowDrop()
},
methods: {
rowDrop() {
console.log(23)
const el = document.querySelector('#table_count .el-table__body-wrapper tbody')
new Sortable(el, {
animation: 150,
handle: '.handle',
ghostClass: 'blue-background-class'
});
}
}
}
</script>
网友评论