demo3.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <m-checkbox-group v-model="checkList1" @change="checkChange">
  3. <m-checkbox label="复选框 A"></m-checkbox>
  4. <m-checkbox label="复选框 B"></m-checkbox>
  5. <m-checkbox label="复选框 C"></m-checkbox>
  6. <m-checkbox label="复选框 D" disabled></m-checkbox>
  7. <m-checkbox label="复选框 E" disabled></m-checkbox>
  8. </m-checkbox-group>
  9. <m-checkbox-group v-model="checkList2" style="margin-top:10px">
  10. <m-checkbox
  11. v-for="(item,index) in checkOptions"
  12. :key="index"
  13. :label="item.label"
  14. :disabled="item.disabled">
  15. </m-checkbox>
  16. </m-checkbox-group>
  17. </template>
  18. <script setup>
  19. import { reactive, ref } from 'vue-demi'
  20. const checkList1 = ref(['复选框 A', '复选框 E'])
  21. const checkList2 = ref([])
  22. const state = reactive({
  23. checkOptions:[
  24. {label:'复选框 A'},
  25. {label:'复选框 B'},
  26. {label:'复选框 C'},
  27. {label:'复选框 D',disabled:true},
  28. {label:'复选框 E',disabled:true}
  29. ]
  30. })
  31. const checkChange = (e) => {
  32. console.log(e);
  33. }
  34. const { checkOptions } = state;
  35. </script>