iview/examples/routers/table.vue

234 lines
8.5 KiB
Vue
Raw Normal View History

<template>
2018-01-19 18:01:21 +08:00
<div>
2018-03-23 15:32:58 +08:00
<br><br><br><br><br>
<Table border :columns="columns1" height="500" :data="data1"></Table>
<br><br><br><br><br>
2018-03-23 17:35:19 +08:00
<Table width="550" height="200" border :columns="columns2" :data="data4"></Table>
2018-03-23 15:32:58 +08:00
<br><br><br><br><br>
2018-01-19 18:01:21 +08:00
</div>
</template>
<script>
export default {
2017-07-19 15:09:15 +08:00
data () {
return {
2018-03-23 15:32:58 +08:00
columns1: [
2017-10-17 10:14:10 +02:00
{
2017-11-08 14:39:39 +08:00
title: 'Name',
2018-03-17 02:16:19 +08:00
key: 'name',
2018-03-23 15:32:58 +08:00
align: 'center',
width: 200,
fixed: 'left'
2018-03-17 02:16:19 +08:00
},
{
2018-03-23 15:32:58 +08:00
title: 'Other',
align: 'center',
children: [
{
title: 'Age',
key: 'age',
align: 'center',
width: 200
},
{
title: 'Address',
align: 'center',
children: [
{
title: 'Street',
key: 'street',
align: 'center',
width: 200
},
{
title: 'Block',
align: 'center',
children: [
{
title: 'Building',
key: 'building',
align: 'center',
width: 200
},
{
title: 'Door No.',
key: 'door',
align: 'center',
width: 200
}
]
}
]
}
]
},
{
title: 'Company',
align: 'center',
children: [
{
title: 'Company Address',
key: 'caddress',
align: 'center',
width: 200
},
{
title: 'Company Name',
key: 'cname',
align: 'center',
width: 200
}
]
},
{
title: 'Gender',
key: 'gender',
align: 'center',
width: 200,
2018-03-23 17:35:19 +08:00
fixed: 'right'
2017-10-17 10:14:10 +02:00
}
2018-03-16 17:22:03 +08:00
],
2018-03-20 19:28:39 +08:00
columns2: [
{
title: 'Name',
key: 'name',
width: 100,
fixed: 'left'
},
{
title: 'Age',
key: 'age',
2018-03-23 15:32:58 +08:00
width: 100,
fixed: 'right',
sortable: true
2018-03-20 19:28:39 +08:00
},
{
title: 'Province',
key: 'province',
width: 100
},
{
title: 'City',
key: 'city',
width: 100
},
{
title: 'Address',
key: 'address',
width: 200
},
{
title: 'Postcode',
key: 'zip',
2018-03-23 15:32:58 +08:00
width: 100
2018-03-20 19:28:39 +08:00
},
{
title: 'Action',
key: 'action',
fixed: 'right',
width: 120,
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'text',
size: 'small'
}
}, 'View'),
h('Button', {
props: {
type: 'text',
size: 'small'
}
}, 'Edit')
]);
}
}
],
2018-03-23 15:32:58 +08:00
data1: [],
data4: [
2018-03-20 19:28:39 +08:00
{
name: 'John Brown',
age: 18,
address: 'New York No. 1 Lake Park',
province: 'America',
city: 'New York',
zip: 100000
},
{
name: 'Jim Green',
age: 24,
address: 'Washington, D.C. No. 1 Lake Park',
province: 'America',
city: 'Washington, D.C.',
zip: 100000
},
{
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
province: 'Australian',
city: 'Sydney',
zip: 100000
},
2018-03-21 21:03:32 +08:00
{
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
province: 'Canada',
city: 'Ottawa',
zip: 100000
},
{
name: 'John Brown',
age: 18,
address: 'New York No. 1 Lake Park',
province: 'America',
city: 'New York',
zip: 100000
},
{
name: 'Jim Green',
age: 24,
address: 'Washington, D.C. No. 1 Lake Park',
province: 'America',
city: 'Washington, D.C.',
zip: 100000
},
{
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
province: 'Australian',
city: 'Sydney',
zip: 100000
},
2018-03-20 19:28:39 +08:00
{
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
province: 'Canada',
city: 'Ottawa',
zip: 100000
}
2018-01-19 18:01:21 +08:00
]
}
},
2018-03-23 15:32:58 +08:00
mounted () {
const data = [];
for (let i = 0; i < 100; i++) {
data.push({
key: i,
name: 'John Brown',
age: i + 1,
street: 'Lake Park',
building: 'C',
door: 2035,
caddress: 'Lake Street 42',
cname: 'SoftLake Co',
gender: 'M',
});
2017-09-20 14:18:45 +08:00
}
2018-03-23 15:32:58 +08:00
this.data1 = data;
}
2017-10-23 19:01:47 +08:00
}
2018-03-21 11:12:31 +08:00
</script>