Blame view

examples/routers/select.vue 3.22 KB
e355dd49   梁灏   add Select Component
1
  <template>
f89dd9c2   梁灏   Paeg、Select add p...
2
      <div style="width: 200px;margin: 100px;">
01b54e30   梁灏   Select support re...
3
4
          <i-select v-model="model" filterable remote :remote-method="remoteMethod" :loading="loading" clearable style="width:200px">
              <i-option v-for="option in options" :value="option.value" :key="option">{{option.label}}</i-option>
f4c38b46   梁灏   fixed #805
5
          </i-select>
01b54e30   梁灏   Select support re...
6
          <!--<Button @click="handleAdd">+</Button>-->
f89dd9c2   梁灏   Paeg、Select add p...
7
      </div>
e355dd49   梁灏   add Select Component
8
  </template>
83b73885   梁灏   fixed #718
9
  
e355dd49   梁灏   add Select Component
10
  <script>
e355dd49   梁灏   add Select Component
11
      export default {
e355dd49   梁灏   add Select Component
12
13
          data () {
              return {
01b54e30   梁灏   Select support re...
14
                  model: '',
f4c38b46   梁灏   fixed #805
15
16
                  options: [
  
01b54e30   梁灏   Select support re...
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                  ],
                  list: [],
                  loading: false,
                  states: ["Alabama", "Alaska", "Arizona",
                      "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
72
                  ]
01b54e30   梁灏   Select support re...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
              },
              remoteMethod (query) {
                  if (query !== '') {
                      this.loading = true;
                      setTimeout(() => {
                          this.loading = false;
                          this.options = this.list.filter(item => {
                              return item.label.toLowerCase()
                                      .indexOf(query.toLowerCase()) > -1;
                          });
                      }, 200);
                  } else {
                      this.options = [];
                  }
e355dd49   梁灏   add Select Component
87
              }
f4c38b46   梁灏   fixed #805
88
89
          },
          mounted () {
01b54e30   梁灏   Select support re...
90
91
92
              this.list = this.states.map(item => {
                  return { value: item, label: item };
              });
e355dd49   梁灏   add Select Component
93
94
          }
      }
83b73885   梁灏   fixed #718
95
  </script>