Blame view

test/routers/transfer.vue 1.43 KB
77f7bb95   梁灏   add Transfer comp...
1
  <template>
9084eb18   梁灏   fixed #92
2
3
4
      <Transfer
              :data="data2"
              :target-keys="targetKeys2"
77f7bb95   梁灏   add Transfer comp...
5
              filterable
3fd97880   梁灏   Transfer renderFo...
6
              :render-format="rf"
122e69ee   梁灏   update Transfer
7
              :filter-method="filterMethod"
9084eb18   梁灏   fixed #92
8
              @on-change="handleChange2"></Transfer>
77f7bb95   梁灏   add Transfer comp...
9
10
  </template>
  <script>
77f7bb95   梁灏   add Transfer comp...
11
      export default {
77f7bb95   梁灏   add Transfer comp...
12
13
          data () {
              return {
9084eb18   梁灏   fixed #92
14
15
                  data2: this.getMockData(),
                  targetKeys2: this.getTargetKeys()
77f7bb95   梁灏   add Transfer comp...
16
17
              }
          },
77f7bb95   梁灏   add Transfer comp...
18
          methods: {
9084eb18   梁灏   fixed #92
19
20
21
22
23
24
25
26
27
28
29
              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;
37ee1535   梁灏   update Transfer
30
              },
9084eb18   梁灏   fixed #92
31
32
33
34
35
36
37
              getTargetKeys () {
                  return this.getMockData()
                          .filter(() => Math.random() * 2 > 1)
                          .map(item => item.key);
              },
              handleChange2 (newTargetKeys) {
                  this.targetKeys2 = newTargetKeys;
122e69ee   梁灏   update Transfer
38
              },
9084eb18   梁灏   fixed #92
39
40
              filterMethod (data, query) {
                  return data.label.indexOf(query) > -1;
3fd97880   梁灏   Transfer renderFo...
41
42
43
              },
              rf (data) {
                  return '<i class="ivu-icon ivu-icon-alert"></i>' + data.label;
77f7bb95   梁灏   add Transfer comp...
44
45
46
              }
          }
      }
9084eb18   梁灏   fixed #92
47
  </script>