Blame view

examples/routers/select.vue 3.09 KB
e355dd49   梁灏   add Select Component
1
  <template>
e9932043   Aresn   fixed #978
2
      <Row>
98bf25b3   梁灏   fixed #1286
3
4
5
6
7
8
9
          <Col span="12" style="padding-right:10px">
          <Select
                  v-model="model13"
                  filterable
                  remote
                  :remote-method="remoteMethod1"
                  :loading="loading1">
82d90c4f   梁灏   update Select exa...
10
              <Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option>
98bf25b3   梁灏   fixed #1286
11
12
13
14
15
16
17
18
19
20
          </Select>
          </Col>
          <Col span="12">
          <Select
                  v-model="model14"
                  multiple
                  filterable
                  remote
                  :remote-method="remoteMethod2"
                  :loading="loading2">
82d90c4f   梁灏   update Select exa...
21
              <Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>
98bf25b3   梁灏   fixed #1286
22
23
          </Select>
          </Col>
e9932043   Aresn   fixed #978
24
      </Row>
e355dd49   梁灏   add Select Component
25
  </template>
e355dd49   梁灏   add Select Component
26
  <script>
e355dd49   梁灏   add Select Component
27
      export default {
e355dd49   梁灏   add Select Component
28
29
          data () {
              return {
98bf25b3   梁灏   fixed #1286
30
31
32
33
34
35
36
                  model13: '',
                  loading1: false,
                  options1: [],
                  model14: [],
                  loading2: false,
                  options2: [],
                  list: ['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'],
01b54e30   梁灏   Select support re...
37
38
              }
          },
01b54e30   梁灏   Select support re...
39
          methods: {
98bf25b3   梁灏   fixed #1286
40
              remoteMethod1 (query) {
e9932043   Aresn   fixed #978
41
                  if (query !== '') {
98bf25b3   梁灏   fixed #1286
42
                      this.loading1 = true;
e9932043   Aresn   fixed #978
43
                      setTimeout(() => {
98bf25b3   梁灏   fixed #1286
44
45
46
47
48
49
                          this.loading1 = false;
                          const list = this.list.map(item => {
                              return {
                                  value: item,
                                  label: item
                              };
e9932043   Aresn   fixed #978
50
                          });
98bf25b3   梁灏   fixed #1286
51
52
                          this.options1 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);
                      }, 200);
e9932043   Aresn   fixed #978
53
                  } else {
98bf25b3   梁灏   fixed #1286
54
                      this.options1 = [];
e9932043   Aresn   fixed #978
55
56
                  }
              },
98bf25b3   梁灏   fixed #1286
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
              remoteMethod2 (query) {
                  if (query !== '') {
                      this.loading2 = true;
                      setTimeout(() => {
                          this.loading2 = false;
                          const list = this.list.map(item => {
                              return {
                                  value: item,
                                  label: item
                              };
                          });
                          this.options2 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);
                      }, 200);
                  } else {
                      this.options2 = [];
                  }
e355dd49   梁灏   add Select Component
73
              }
e355dd49   梁灏   add Select Component
74
75
          }
      }
219e5c92   梁灏   fixed #957
76
  </script>