ant-design-vue/components/transfer/demo/large-data.md

60 lines
1.2 KiB
Markdown
Raw Normal View History

2018-04-07 00:20:45 +08:00
<cn>
#### 大数据性能测试
2000 条数据。
</cn>
<us>
#### Performance Test
2000 items.
</us>
2019-10-09 18:32:23 +08:00
```tpl
2018-04-07 00:20:45 +08:00
<template>
<a-transfer
:dataSource="mockData"
:targetKeys="targetKeys"
@change="handleChange"
:render="item=>item.title"
showSearch
2018-04-07 00:20:45 +08:00
>
</a-transfer>
</template>
<script>
2019-09-28 20:45:07 +08:00
export default {
data() {
return {
mockData: [],
targetKeys: [],
};
},
mounted() {
this.getMock();
2018-04-07 00:20:45 +08:00
},
2019-09-28 20:45:07 +08:00
methods: {
getMock() {
const targetKeys = [];
const mockData = [];
for (let i = 0; i < 2000; i++) {
const data = {
key: i.toString(),
title: `content${i + 1}`,
description: `description of content${i + 1}`,
chosen: Math.random() * 2 > 1,
};
if (data.chosen) {
targetKeys.push(data.key);
}
mockData.push(data);
}
this.mockData = mockData;
this.targetKeys = targetKeys;
},
handleChange(targetKeys, direction, moveKeys) {
console.log(targetKeys, direction, moveKeys);
this.targetKeys = targetKeys;
},
2018-04-07 00:20:45 +08:00
},
2019-09-28 20:45:07 +08:00
};
2018-04-07 00:20:45 +08:00
</script>
```