iview/examples/routers/table.vue

160 lines
6 KiB
Vue
Raw Normal View History

2019-08-27 09:42:40 +08:00
<template>
2019-12-19 20:06:01 +08:00
<div style="margin: 100px;">
2020-01-06 17:32:29 +08:00
<Table
border
highlight-row
@on-current-change="occ"
@on-row-click="orc"
ref="selection"
:columns="columns4"
:data="data1"
row-key="id">
2020-01-06 11:17:09 +08:00
<template slot-scope="{ row }" slot="age">
<strong>{{row.age}}</strong>
</template>
</Table>
2020-01-06 16:14:09 +08:00
<br><br>
2019-12-19 20:06:01 +08:00
<Button @click="handleSelectAll(true)">Set all selected</Button>
<Button @click="handleSelectAll(false)">Cancel all selected</Button>
2019-08-27 09:42:40 +08:00
</div>
</template>
<script>
export default {
data () {
return {
2019-09-20 20:00:00 +08:00
columns4: [
2020-01-06 16:14:09 +08:00
// {
// type: 'index',
// width: 60,
// align: 'center'
// },
2019-08-27 09:42:40 +08:00
{
2019-12-19 20:06:01 +08:00
type: 'selection',
width: 60,
align: 'center'
2019-09-20 20:00:00 +08:00
},
{
title: 'Name',
key: 'name',
2019-12-19 20:06:01 +08:00
tree: true
2019-08-27 09:42:40 +08:00
},
{
title: 'Age',
2020-01-06 11:17:09 +08:00
// key: 'age',
slot: 'age'
2019-08-27 09:42:40 +08:00
},
2020-01-03 14:18:33 +08:00
{
title: 'Date',
key: 'date'
},
2019-08-27 09:42:40 +08:00
{
title: 'Address',
2019-09-20 20:00:00 +08:00
key: 'address'
2019-08-27 09:42:40 +08:00
}
],
data1: [
{
2020-01-06 11:17:09 +08:00
id: '100',
2019-08-27 09:42:40 +08:00
name: 'John Brown',
age: 18,
2019-09-20 20:00:00 +08:00
address: 'New York No. 1 Lake Park',
2019-08-27 09:42:40 +08:00
date: '2016-10-03'
},
{
2020-01-06 11:17:09 +08:00
id: '101',
2019-08-27 09:42:40 +08:00
name: 'Jim Green',
age: 24,
2019-09-20 20:00:00 +08:00
address: 'London No. 1 Lake Park',
2019-12-19 20:06:01 +08:00
date: '2016-10-01',
2020-01-06 11:17:09 +08:00
_showChildren: true,
2019-12-19 20:06:01 +08:00
children: [
2019-09-20 20:00:00 +08:00
{
2020-01-06 11:17:09 +08:00
id: '10100',
2019-12-19 20:06:01 +08:00
name: '张三',
age: 18,
address: '发动机莲富大厦放假了开始的',
date: '2016-10-01'
2019-09-20 20:00:00 +08:00
},
{
2020-01-06 11:17:09 +08:00
id: '10101',
2019-12-19 20:06:01 +08:00
name: '李四',
age: 19,
address: '风刀霜剑分离的思路开发',
date: '2016-10-02'
2019-09-20 20:00:00 +08:00
},
{
2020-01-06 11:17:09 +08:00
id: '10102',
2019-12-19 20:06:01 +08:00
name: '王五',
age: 20,
address: '分离的付款就说个就是范德萨发生',
date: '2016-10-03',
2020-01-06 11:17:09 +08:00
_showChildren: true,
2019-09-20 20:00:00 +08:00
children: [
{
2020-01-06 11:17:09 +08:00
id: '10102100',
2019-12-19 20:06:01 +08:00
name: '赵六',
age: 21,
address: '梵蒂冈人太热疼我',
date: '2016-10-05'
2019-09-20 20:00:00 +08:00
},
{
2020-01-06 11:17:09 +08:00
id: '10102101',
2019-12-19 20:06:01 +08:00
name: '丁八',
age: 22,
address: '法第三方的范德萨范德萨发送到',
date: '2016-10-06',
2020-01-06 11:17:09 +08:00
_showChildren: true,
2019-09-20 20:00:00 +08:00
children: [
{
2020-01-06 11:17:09 +08:00
id: '10102101100',
2019-12-19 20:06:01 +08:00
name: '第九',
age: 23,
address: '9梵蒂冈人太热疼我',
date: '2016-10-07'
2019-09-20 20:00:00 +08:00
},
{
2020-01-06 11:17:09 +08:00
id: '10102101101',
2019-12-19 20:06:01 +08:00
name: '第十',
age: 24,
address: '10法第三方的范德萨范德萨发送到',
date: '2016-10-08'
},
2019-09-20 20:00:00 +08:00
]
2019-12-19 20:06:01 +08:00
},
2019-09-20 20:00:00 +08:00
]
}
]
},
{
2020-01-06 11:17:09 +08:00
id: '102',
2019-12-19 20:06:01 +08:00
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
date: '2016-10-02'
2019-09-20 20:00:00 +08:00
},
{
2020-01-06 11:17:09 +08:00
id: '103',
2019-12-19 20:06:01 +08:00
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
date: '2016-10-04'
2019-09-20 20:00:00 +08:00
}
2019-12-19 20:06:01 +08:00
]
2019-08-27 09:42:40 +08:00
}
},
methods: {
2019-12-19 20:06:01 +08:00
handleSelectAll (status) {
this.$refs.selection.selectAll(status);
2020-01-06 16:14:09 +08:00
},
occ (n, o) {
2020-01-06 17:32:29 +08:00
// console.log(n);
// console.log(o);
},
orc (data, index) {
console.log(data);
console.log(index);
2019-08-27 09:42:40 +08:00
}
}
}
</script>