4aaa65df10f8f2685fda4e2715271cda74c81ccf.svn-base 826 B

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