Blame view

examples/routers/select.vue 3.51 KB
e355dd49   梁灏   add Select Component
1
  <template>
d87ce40a   梁灏   update Select
2
3
4
      <Row>
          <i-col span="4">{{model}}</i-col>
          <i-col span="8">
ddc35c9a   梁灏   fixed #952
5
              <i-select v-model="model" :label="['L Alabama', 'L Hawaii']" multiple @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable>
7dcfe45d   梁灏   update Select
6
                  <i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option>
d87ce40a   梁灏   update Select
7
8
9
              </i-select>
          </i-col>
      </Row>
e355dd49   梁灏   add Select Component
10
  </template>
83b73885   梁灏   fixed #718
11
  
e355dd49   梁灏   add Select Component
12
  <script>
e355dd49   梁灏   add Select Component
13
      export default {
e355dd49   梁灏   add Select Component
14
15
          data () {
              return {
ddc35c9a   梁灏   fixed #952
16
17
  //                model: 'Alabama',
                  model: ['Alabama', 'Hawaii'],
f4c38b46   梁灏   fixed #805
18
19
                  options: [
  
01b54e30   梁灏   Select support re...
20
21
22
                  ],
                  list: [],
                  loading: false,
0b916a32   梁灏   update Select
23
                  states: ["Al", "Alabama", "Alaska", "Arizona",
01b54e30   梁灏   Select support re...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                      "Arkansas", "California", "Colorado",
                      "Connecticut", "Delaware", "Florida",
                      "Georgia", "Hawaii", "Idaho", "Illinois",
                      "Indiana", "Iowa", "Kansas", "Kentucky",
                      "Louisiana", "Maine", "Maryland",
                      "Massachusetts", "Michigan", "Minnesota",
                      "Mississippi", "Missouri", "Montana",
                      "Nebraska", "Nevada", "New Hampshire",
                      "New Jersey", "New Mexico", "New York",
                      "North Carolina", "North Dakota", "Ohio",
                      "Oklahoma", "Oregon", "Pennsylvania",
                      "Rhode Island", "South Carolina",
                      "South Dakota", "Tennessee", "Texas",
                      "Utah", "Vermont", "Virginia",
                      "Washington", "West Virginia", "Wisconsin",
                      "Wyoming"]
              }
          },
          mounted () {
              this.options = [
  //                {
  //                    label: '全部',
  //                    value: 0
  //                },{
  //                    label: '苹果',
  //                    value: 1
  //                },{
  //                    label: '香蕉',
  //                    value: 2
  //                },{
  //                    label: '西瓜',
  //                    value: 3
  //                }
              ];
          },
          methods: {
              handleAdd () {
                  this.options = [
                      {
                          label: '全部',
                          value: 0
                      },{
                          label: '苹果',
                          value: 1
                      },{
                          label: '香蕉',
                          value: 2
                      },{
                          label: '西瓜',
                          value: 3
                      }
f4c38b46   梁灏   fixed #805
75
                  ]
01b54e30   梁灏   Select support re...
76
77
              },
              remoteMethod (query) {
ddc35c9a   梁灏   fixed #952
78
                  console.log(13)
01b54e30   梁灏   Select support re...
79
80
81
82
83
84
85
86
                  if (query !== '') {
                      this.loading = true;
                      setTimeout(() => {
                          this.loading = false;
                          this.options = this.list.filter(item => {
                              return item.label.toLowerCase()
                                      .indexOf(query.toLowerCase()) > -1;
                          });
7dcfe45d   梁灏   update Select
87
                      }, 500);
01b54e30   梁灏   Select support re...
88
89
90
                  } else {
                      this.options = [];
                  }
7dcfe45d   梁灏   update Select
91
92
93
              },
              handleInput () {
  //                console.log(1)
e355dd49   梁灏   add Select Component
94
              }
f4c38b46   梁灏   fixed #805
95
96
          },
          mounted () {
01b54e30   梁灏   Select support re...
97
              this.list = this.states.map(item => {
c70ff0f2   梁灏   fixed #915
98
99
100
101
                  return {
                      value: item,
                      label: 'L ' + item
                  };
01b54e30   梁灏   Select support re...
102
              });
e355dd49   梁灏   add Select Component
103
104
          }
      }
83b73885   梁灏   fixed #718
105
  </script>