iview/examples/routers/table.vue

73 lines
2.9 KiB
Vue
Raw Normal View History

<template>
2018-01-19 18:01:21 +08:00
<div>
2019-03-04 17:34:48 +08:00
<Table tooltip-theme="light" ref="currentRowTable" :columns="columns3" :data="data1" :draggable="true" @on-drag-drop="onDragDrop"></Table>
2018-06-29 10:04:02 +08:00
<Button @click="handleClearCurrentRow">Clear</Button>
2018-01-19 18:01:21 +08:00
</div>
</template>
<script>
export default {
2017-07-19 15:09:15 +08:00
data () {
return {
2018-06-29 10:04:02 +08:00
columns3: [
2017-12-25 10:26:54 +08:00
{
2018-06-29 10:04:02 +08:00
type: 'index',
2018-01-19 18:01:21 +08:00
width: 60,
2018-06-29 10:04:02 +08:00
align: 'center',
indexMethod (row) {
return row._index;
}
2017-12-25 10:26:54 +08:00
},
2017-10-17 10:14:10 +02:00
{
2017-11-08 14:39:39 +08:00
title: 'Name',
2017-12-25 10:26:54 +08:00
key: 'name'
2017-10-26 11:26:05 +08:00
},
{
2017-11-08 14:39:39 +08:00
title: 'Age',
2018-01-19 18:01:21 +08:00
key: 'age'
2017-10-26 11:26:05 +08:00
},
{
2017-11-08 14:39:39 +08:00
title: 'Address',
2018-06-29 11:24:26 +08:00
key: 'address',
tooltip: true
2017-10-17 10:14:10 +02:00
}
],
2018-01-19 18:01:21 +08:00
data1: [
2017-11-08 16:11:04 +08:00
{
name: 'John Brown',
age: 18,
2018-06-29 11:24:26 +08:00
address: '自定义渲染列,使用 Vue 的 Render 函数。传入两个参数,第一个是 h第二个为对象包含 row、column 和 index分别指当前行数据当前列数据当前行索引详见示例。自定义渲染列使用 Vue 的 Render 函数。传入两个参数,第一个是 h第二个为对象包含 row、column 和 index分别指当前行数据当前列数据当前行索引详见示例。自定义渲染列使用 Vue 的 Render 函数。传入两个参数,第一个是 h第二个为对象包含 row、column 和 index分别指当前行数据当前列数据当前行索引详见示例。',
2017-12-25 10:26:54 +08:00
date: '2016-10-03'
2017-11-08 16:11:04 +08:00
},
{
name: 'Jim Green',
age: 24,
2018-06-29 11:24:26 +08:00
address: 'London No. 1 Lake Park自定义渲染列使用 Vue 的 Render 函',
2017-12-25 10:26:54 +08:00
date: '2016-10-01'
2017-11-08 16:11:04 +08:00
},
{
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
2017-12-25 10:26:54 +08:00
date: '2016-10-02'
2017-11-08 16:11:04 +08:00
},
{
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
2017-12-25 10:26:54 +08:00
date: '2016-10-04'
2017-10-17 10:14:10 +02:00
}
2018-06-25 20:27:03 +08:00
]
}
},
methods: {
2018-06-29 10:04:02 +08:00
handleClearCurrentRow () {
this.$refs.currentRowTable.clearCurrentRow();
2018-10-29 14:46:27 +08:00
},
onDragDrop(a,b){
2019-03-04 16:44:18 +08:00
console.log(a,b);
this.data1.splice(b,1,...this.data1.splice(a, 1 , this.data1[b]));
2017-09-20 14:18:45 +08:00
}
}
2017-10-23 19:01:47 +08:00
}
2017-09-03 12:26:16 +08:00
</script>