ant-design-vue/components/vc-table/demo/scrollY.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-27 14:41:41 +00:00
/* eslint-disable no-console,func-names,react/no-multi-comp */
2019-01-12 03:33:27 +00:00
import Table from '../index';
import '../assets/index.less';
2018-03-27 14:41:41 +00:00
2019-01-12 03:33:27 +00:00
const data = [];
2018-03-27 14:41:41 +00:00
for (let i = 0; i < 10; i++) {
data.push({
key: i,
a: `a${i}`,
b: `b${i}`,
c: `c${i}`,
2019-01-12 03:33:27 +00:00
});
2018-03-27 14:41:41 +00:00
}
export default {
2019-01-12 03:33:27 +00:00
data() {
2018-03-27 14:41:41 +00:00
return {
showBody: true,
2019-01-12 03:33:27 +00:00
};
2018-03-27 14:41:41 +00:00
},
methods: {
2019-01-12 03:33:27 +00:00
toggleBody() {
this.showBody = !this.showBody;
2018-03-27 14:41:41 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
2018-03-27 14:41:41 +00:00
const columns = [
{ title: 'title1', key: 'a', dataIndex: 'a', width: 100 },
{ id: '123', title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
{ title: 'title3', key: 'c', dataIndex: 'c', width: 200 },
{
2019-01-12 03:33:27 +00:00
title: (
<a onClick={this.toggleBody} href="javascript:;">
{this.showBody ? '隐藏' : '显示'}
</a>
),
2018-03-27 14:41:41 +00:00
key: 'x',
width: 200,
2019-01-12 03:33:27 +00:00
customRender() {
return <a href="#">Operations</a>;
2018-03-27 14:41:41 +00:00
},
},
2019-01-12 03:33:27 +00:00
];
2018-03-27 14:41:41 +00:00
return (
<div>
<h2>scroll body table</h2>
<Table
columns={columns}
data={data}
scroll={{ y: 300 }}
rowKey={record => record.key}
bodyStyle={{
display: this.showBody ? '' : 'none',
}}
/>
</div>
2019-01-12 03:33:27 +00:00
);
2018-03-27 14:41:41 +00:00
},
2019-01-12 03:33:27 +00:00
};