diff --git a/src/module/checkbox/index.vue b/src/module/checkbox/index.vue index 8b79bfdf..63d0afda 100644 --- a/src/module/checkbox/index.vue +++ b/src/module/checkbox/index.vue @@ -8,7 +8,7 @@ 'layui-checkbox-disbaled layui-disabled': disabled, }, 'layui-form-checkbox', - hasValue ? 'layui-form-checked' : '', + props.modelValue.includes(props.label) ? 'layui-form-checked' : '', ]" :lay-skin="skin" > @@ -24,7 +24,7 @@ import { defineProps, ref, watch } from 'vue' const props = defineProps<{ - modelValue: Array + modelValue: string[] label: string disabled?: boolean name?: string @@ -33,14 +33,6 @@ const props = const hasValue = ref(false) -watch(props.modelValue, (val) => { - if (props.modelValue.includes(props.label)) { - hasValue.value = true - } else { - hasValue.value = false - } -},{immediate: true}) - const emit = defineEmits(['update:modelValue']) const handleClick = function () { @@ -51,14 +43,6 @@ const handleClick = function () { let index = props.modelValue.indexOf(props.label) props.modelValue.splice(index, 1) } - props.modelValue.includes(props.label) - ? (hasValue.value = true) - : (hasValue.value = false) - if (props.modelValue.includes(props.label)) { - hasValue.value = true - } else { - hasValue.value = false - } emit('update:modelValue', props.modelValue) } } diff --git a/src/module/menuItem/index.vue b/src/module/menuItem/index.vue index a8de1a1e..efbd4d6a 100644 --- a/src/module/menuItem/index.vue +++ b/src/module/menuItem/index.vue @@ -26,7 +26,7 @@