Blame view

src/components/select/option-group.vue 1.36 KB
e355dd49   梁灏   add Select Component
1
  <template>
f5ecd167   梁灏   fixed #186
2
      <li :class="[prefixCls + '-wrap']" v-show="!hidden">
d6342fe1   jingsam   fixed ie bug
3
          <div :class="[prefixCls + '-title']">{{ label }}</div>
e355dd49   梁灏   add Select Component
4
          <ul>
4aec6a66   梁灏   support Select
5
              <li :class="[prefixCls]" ref="options"><slot></slot></li>
e355dd49   梁灏   add Select Component
6
7
8
9
10
11
12
          </ul>
      </li>
  </template>
  <script>
      const prefixCls = 'ivu-select-group';
  
      export default {
4aec6a66   梁灏   support Select
13
          name: 'OptionGroup',
e355dd49   梁灏   add Select Component
14
15
16
17
18
19
20
21
          props: {
              label: {
                  type: String,
                  default: ''
              }
          },
          data () {
              return {
f5ecd167   梁灏   fixed #186
22
23
                  prefixCls: prefixCls,
                  hidden: false    // for search
b0893113   jingsam   :art: add eslint
24
              };
f5ecd167   梁灏   fixed #186
25
26
27
28
          },
          methods: {
              queryChange () {
                  this.$nextTick(() => {
4aec6a66   梁灏   support Select
29
                      const options = this.$refs.options.querySelectorAll('.ivu-select-item');
f5ecd167   梁灏   fixed #186
30
31
32
33
34
35
36
37
38
39
40
                      let hasVisibleOption = false;
                      for (let i = 0; i < options.length; i++) {
                          if (options[i].style.display !== 'none') {
                              hasVisibleOption = true;
                              break;
                          }
                      }
                      this.hidden = !hasVisibleOption;
                  });
              }
          },
4aec6a66   梁灏   support Select
41
42
          mounted () {
              this.$on('on-query-change', () => {
f5ecd167   梁灏   fixed #186
43
44
                  this.queryChange();
                  return true;
4aec6a66   梁灏   support Select
45
              });
e355dd49   梁灏   add Select Component
46
          }
b0893113   jingsam   :art: add eslint
47
      };
d6342fe1   jingsam   fixed ie bug
48
  </script>