transfer.vue
1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
<Transfer
:data="data2"
:target-keys="targetKeys2"
filterable
:render-format="rf"
:filter-method="filterMethod"
@on-change="handleChange2"></Transfer>
</template>
<script>
export default {
data () {
return {
data2: this.getMockData(),
targetKeys2: this.getTargetKeys()
}
},
methods: {
getMockData () {
let mockData = [];
for (let i = 1; i <= 20; i++) {
mockData.push({
key: i.toString(),
label: '内容' + i,
description: '内容' + i + '的描述信息',
disabled: Math.random() * 3 < 1
});
}
return mockData;
},
getTargetKeys () {
return this.getMockData()
.filter(() => Math.random() * 2 > 1)
.map(item => item.key);
},
handleChange2 (newTargetKeys) {
this.targetKeys2 = newTargetKeys;
},
filterMethod (data, query) {
return data.label.indexOf(query) > -1;
},
rf (data) {
return '<i class="ivu-icon ivu-icon-alert"></i>' + data.label;
}
}
}
</script>