index.vue 747 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <a-checkbox :val="_val" @change="handleChange" :checked="chackboxVal">
  3. {{ label }}
  4. </a-checkbox>
  5. </template>
  6. <script>
  7. /*
  8. * author kcz
  9. * date 2019-11-20
  10. * description 多选框组件,改成v-model Boolean值
  11. */
  12. export default {
  13. name: "kCheckbox",
  14. data() {
  15. return {
  16. chackboxVal: false
  17. };
  18. },
  19. props: {
  20. value: {
  21. type: Boolean,
  22. default: false
  23. },
  24. label: {
  25. type: String,
  26. default: ""
  27. }
  28. },
  29. computed: {
  30. _val() {
  31. this.handleSetChackboxVal(this.value);
  32. return this.value;
  33. }
  34. },
  35. methods: {
  36. handleChange(e) {
  37. this.$emit("input", e.target.checked);
  38. },
  39. handleSetChackboxVal(val) {
  40. this.chackboxVal = val;
  41. }
  42. }
  43. };
  44. </script>