2018-04-06 16:20:45 +00:00
|
|
|
<cn>
|
|
|
|
#### 高级用法
|
|
|
|
穿梭框高级用法,可配置操作文案,可定制宽高,可对底部进行自定义渲染。
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### Advanced
|
|
|
|
You can customize the labels of the transfer buttons, the width and height of the columns, and what should be displayed in the footer.
|
|
|
|
</us>
|
|
|
|
|
2019-10-09 10:32:23 +00:00
|
|
|
```tpl
|
2018-04-06 16:20:45 +00:00
|
|
|
<template>
|
|
|
|
<a-transfer
|
|
|
|
:dataSource="mockData"
|
|
|
|
showSearch
|
|
|
|
:listStyle="{
|
|
|
|
width: '250px',
|
|
|
|
height: '300px',
|
|
|
|
}"
|
|
|
|
:operations="['to right', 'to left']"
|
|
|
|
:targetKeys="targetKeys"
|
|
|
|
@change="handleChange"
|
|
|
|
:render="item=>`${item.title}-${item.description}`"
|
|
|
|
>
|
|
|
|
<a-button
|
|
|
|
size="small"
|
|
|
|
style="float:right;margin: 5px"
|
|
|
|
@click="getMock"
|
|
|
|
slot="footer"
|
|
|
|
slot-scope="props"
|
|
|
|
>
|
|
|
|
reload
|
|
|
|
</a-button>
|
2019-09-28 12:45:07 +00:00
|
|
|
<span slot="notFoundContent">
|
2018-04-06 16:20:45 +00:00
|
|
|
没数据
|
|
|
|
</span>
|
|
|
|
</a-transfer>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-09-28 12:45:07 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mockData: [],
|
|
|
|
targetKeys: [],
|
|
|
|
};
|
2018-04-06 16:20:45 +00:00
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
mounted() {
|
|
|
|
this.getMock();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getMock() {
|
|
|
|
const targetKeys = [];
|
|
|
|
const mockData = [];
|
|
|
|
for (let i = 0; i < 20; 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-06 16:20:45 +00:00
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
};
|
2018-04-06 16:20:45 +00:00
|
|
|
</script>
|
|
|
|
```
|