Blame view

src/components/checkbox/checkbox-group.vue 1.22 KB
7fa943eb   梁灏   init
1
2
3
4
5
6
7
8
9
  <template>
      <div :class="classes">
          <slot></slot>
      </div>
  </template>
  <script>
      const prefixCls = 'ivu-checkbox-group';
  
      export default {
829a2e4c   梁灏   fixed CheckboxGro...
10
          name: 'checkboxGroup',
7fa943eb   梁灏   init
11
12
13
          props: {
              model: {
                  type: Array,
6ff31952   梁灏   optimize Input sh...
14
                  default () {
b0893113   jingsam   :art: add eslint
15
                      return [];
6ff31952   梁灏   optimize Input sh...
16
                  }
7fa943eb   梁灏   init
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
              }
          },
          computed: {
              classes () {
                  return `${prefixCls}`;
              }
          },
          compiled () {
              this.updateModel(true);
          },
          methods: {
              updateModel (update) {
                  const model = this.model;
  
                  this.$children.forEach((child) => {
                      child.model = model;
  
                      if (update) {
                          child.selected = model.indexOf(child.value) >= 0;
                          child.group = true;
                      }
                  });
              },
              change (data) {
39e6e965   梁灏   fixed checkbox bu...
41
                  this.model = data;
7fa943eb   梁灏   init
42
                  this.$emit('on-change', data);
f65e9be5   梁灏   update checkboxGroup
43
                  this.$dispatch('on-form-change', data);
7fa943eb   梁灏   init
44
45
46
              }
          },
          watch: {
b0893113   jingsam   :art: add eslint
47
              model () {
c1f6da1f   梁灏   fixed CheckboxGro...
48
                  this.updateModel(true);
7fa943eb   梁灏   init
49
50
              }
          }
b0893113   jingsam   :art: add eslint
51
52
      };
  </script>