Blame view

ant-design-vue-jeecg/src/components/jeecg/JCheckbox.vue 763 Bytes
肖超群 authored
1
<template>
肖超群 authored
2
  <a-checkbox-group :options="options" :value="checkboxArray" v-bind="$attrs" @change="onChange"/>
肖超群 authored
3
4
5
</template>

<script>
肖超群 authored
6
7
8
9
10
11
export default {
  name: 'JCheckbox',
  props: {
    value: {
      type: String,
      required: false
肖超群 authored
12
    },
肖超群 authored
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    /*label value*/
    options: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
      checkboxArray: !this.value ? [] : this.value.split(",")
    }
  },
  watch: {
    value(val) {
      if (!val) {
        this.checkboxArray = []
      } else {
        this.checkboxArray = this.value.split(",")
肖超群 authored
30
31
      }
    }
肖超群 authored
32
33
34
35
36
37
38
39
40
  },
  methods: {
    onChange(checkedValues) {
      this.$emit('change', checkedValues.join(","));
    },
  },
  model: {
    prop: 'value',
    event: 'change'
肖超群 authored
41
  }
肖超群 authored
42
}
肖超群 authored
43
</script>