JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//unpkg.com/sortablejs@1.7.0/Sortable.js"></script>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.4.0/lib/index.js"></script>
<div id="app">
<template>
<el-dialog visible>
<el-table row-key="date" ref="table" border :data="tableData" style="width: 100%">
<el-table-column prop="date" label="日期" width="180">
<template slot-scope="scope"> {{ scope.row.date }} </template>
</el-table-column>
<el-table-column prop="name" label="姓名" width="180">
</el-table-column>
<el-table-column prop="address" label="地址">
</el-table-column>
</el-table>
</el-dialog>
<pre>{{ tableData }}</pre>
</template>
</div>
SCSS
@import url("//unpkg.com/element-ui@2.0.5/lib/theme-chalk/index.css");
Babel + JSX
var Main = {
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}]
}
},
async mounted() {
const sleep = (time) => new Promise(resolve => setTimeout(resolve, time))
await sleep(1)
const table = document.querySelector('.el-table__body-wrapper tbody')
const self = this
Sortable.create(table, {
onEnd({ newIndex, oldIndex }) {
const targetRow = self.tableData.splice(oldIndex, 1)[0]
self.tableData.splice(newIndex, 0, targetRow)
}
})
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')