Commit 8fbc8c719138ec80cece94f328b26731beb9badd

Authored by 梁灏
1 parent 48af1359

fixed #555

examples/routers/transfer.vue
1   -<template>
2   - <div>
3   - <Transfer
4   - :data="data1"
5   - filterable
6   - :target-keys="targetKeys1"
7   - :render-format="render1"
8   - @on-change="handleChange1"></Transfer>
9   - </div>
10   -</template>
11   -<script>
12   - export default {
13   - data () {
14   - return {
15   - data1: this.getMockData(),
16   - targetKeys1: this.getTargetKeys()
17   - }
18   - },
19   - methods: {
20   - getMockData () {
21   - let mockData = [];
22   - for (let i = 1; i <= 20; i++) {
23   - mockData.push({
24   - key: i.toString(),
25   - label: '内容' + i,
26   - description: '内容' + i + '的描述信息',
27   - disabled: Math.random() * 3 < 1
28   - });
29   - }
30   - return mockData;
31   - },
32   - getTargetKeys () {
33   - return this.getMockData()
34   - .filter(() => Math.random() * 2 > 1)
35   - .map(item => item.key);
36   - },
37   - render1 (item) {
38   - return item.label;
39   - },
40   - handleChange1 (newTargetKeys, direction, moveKeys) {
41   - console.log(newTargetKeys);
42   - console.log(direction);
43   - console.log(moveKeys);
44   - this.targetKeys1 = newTargetKeys;
45   - }
46   - }
47   - }
48   -</script>
  1 +<!--<template>-->
  2 + <!--<div>-->
  3 + <!--<Transfer-->
  4 + <!--:data="data1"-->
  5 + <!--filterable-->
  6 + <!--:target-keys="targetKeys1"-->
  7 + <!--:render-format="render1"-->
  8 + <!--@on-change="handleChange1"></Transfer>-->
  9 + <!--</div>-->
  10 +<!--</template>-->
  11 +<!--<script>-->
  12 + <!--export default {-->
  13 + <!--data () {-->
  14 + <!--return {-->
  15 + <!--data1: this.getMockData(),-->
  16 + <!--targetKeys1: this.getTargetKeys()-->
  17 + <!--}-->
  18 + <!--},-->
  19 + <!--methods: {-->
  20 + <!--getMockData () {-->
  21 + <!--let mockData = [];-->
  22 + <!--for (let i = 1; i <= 20; i++) {-->
  23 + <!--mockData.push({-->
  24 + <!--key: i.toString(),-->
  25 + <!--label: '内容' + i,-->
  26 + <!--description: '内容' + i + '的描述信息',-->
  27 + <!--disabled: Math.random() * 3 < 1-->
  28 + <!--});-->
  29 + <!--}-->
  30 + <!--return mockData;-->
  31 + <!--},-->
  32 + <!--getTargetKeys () {-->
  33 + <!--return this.getMockData()-->
  34 + <!--.filter(() => Math.random() * 2 > 1)-->
  35 + <!--.map(item => item.key);-->
  36 + <!--},-->
  37 + <!--render1 (item) {-->
  38 + <!--return item.label;-->
  39 + <!--},-->
  40 + <!--handleChange1 (newTargetKeys, direction, moveKeys) {-->
  41 + <!--console.log(newTargetKeys);-->
  42 + <!--console.log(direction);-->
  43 + <!--console.log(moveKeys);-->
  44 + <!--this.targetKeys1 = newTargetKeys;-->
  45 + <!--}-->
  46 + <!--}-->
  47 + <!--}-->
  48 +<!--</script>-->
49 49  
50 50  
51 51 <!--<template>-->
... ... @@ -148,3 +148,79 @@
148 148 <!--}-->
149 149 <!--}-->
150 150 <!--</script>-->
  151 +
  152 +
  153 +<template>
  154 + <div>
  155 + <Transfer
  156 + :data="data1"
  157 + filterable
  158 + :target-keys="targetKeys1"
  159 + :render-format="render1"
  160 + @on-change="handleChange1"></Transfer>
  161 + </div>
  162 +</template>
  163 +<script>
  164 + export default {
  165 + data () {
  166 + return {
  167 + data1: this.getMockData(),
  168 + targetKeys1: this.getTargetKeys()
  169 + }
  170 + },
  171 + created(){
  172 + console.log('--created--');
  173 + this.fetch();
  174 + },
  175 + methods: {
  176 + fetch() {
  177 + const _this = this;
  178 + setTimeout(function() {
  179 + console.log('--1');
  180 + // _this.data1 = null;
  181 + _this.data1 = _this.getMockData1();
  182 + console.log('-fetch-', _this.data1);
  183 +
  184 + }, 1500);
  185 + },
  186 + getMockData () {
  187 + let mockData = [];
  188 + for (let i = 1; i <= 20; i++) {
  189 + mockData.push({
  190 + key: i.toString(),
  191 + label: '内容' + i,
  192 + description: '内容' + i + '的描述信息',
  193 + disabled: Math.random() * 3 < 1
  194 + });
  195 + }
  196 + return mockData;
  197 + },
  198 + getMockData1 () {
  199 + let mockData = [];
  200 + for (let i = 1; i <= 20; i++) {
  201 + mockData.push({
  202 + key: i.toString(),
  203 + label: '内容11111' + i,
  204 + description: '内容11111 ' + i + ' 1111的描述信息',
  205 + // disabled: Math.random() * 3 < 1
  206 + });
  207 + }
  208 + return mockData;
  209 + },
  210 + getTargetKeys () {
  211 + return this.getMockData()
  212 + .filter(() => Math.random() * 2 > 1)
  213 + .map(item => item.key);
  214 + },
  215 + render1 (item) {
  216 + return item.label;
  217 + },
  218 + handleChange1 (newTargetKeys, direction, moveKeys) {
  219 + console.log(newTargetKeys);
  220 + console.log(direction);
  221 + console.log(moveKeys);
  222 + this.targetKeys1 = newTargetKeys;
  223 + }
  224 + }
  225 + }
  226 +</script>
151 227 \ No newline at end of file
... ...
src/components/transfer/transfer.vue
... ... @@ -244,6 +244,9 @@
244 244 watch: {
245 245 targetKeys () {
246 246 this.splitData(false);
  247 + },
  248 + data () {
  249 + this.splitData(false);
247 250 }
248 251 },
249 252 created () {
... ...