--demand 面授课

This commit is contained in:
yuping
2023-03-18 00:32:32 +08:00
parent f349acaa75
commit 8c7755c1c4
3 changed files with 25 additions and 20 deletions

View File

@@ -1,24 +1,29 @@
<template>
<a-checkbox @change="change">
<a-checkbox v-model:checked="checked" @change="change">
<slot></slot>
</a-checkbox>
</template>
<script setup>
import {defineEmits, defineProps} from "vue";
import {defineEmits, defineProps, ref, watchEffect} from "vue";
const props = defineProps({
checkValue: {
type: Boolean,
default: true
},
unCheckValue: {
type: Boolean,
modelValue: {
type: [Boolean, Number, String],
default: false
},
checkValue: {
type: [Boolean, Number, String],
default: false
},
unCheckValue: {
type: [Boolean, Number, String],
default: true
},
});
const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(["update:modelValue"]);
const checked = ref(props.modelValue);
watchEffect(() => checked.value = props.modelValue);
const change = ({ target: { checked } }) => emit("update:modelValue", checked ? props.checkValue : props.unCheckValue);
function change({ target: { checked } }) {
emit("update:modelValue", checked ? props.checkValue : props.unCheckValue);
}
</script>