[新增] checkbox-group 复选框组

This commit is contained in:
就眠儀式
2021-11-19 00:42:26 +08:00
parent 8ac00ad877
commit 5c0055719a
4 changed files with 118 additions and 11 deletions

View File

@@ -1,8 +1,45 @@
<template>
<div class="layui-checkbox-group"></div>
<div class="layui-checkbox-group">
<slot></slot>
</div>
</template>
<script setup name="LayCheckbox" lang="ts">
import { defineProps, ref, watch } from 'vue'
<script lang="ts">
export default {
name: "LayCheckboxGroup",
};
</script>
<script setup lang="ts">
import { computed, defineProps, provide, ref, watch } from "vue";
import { Recordable } from "../type";
export interface LayCheckboxGroupProps {
modelValue?: Recordable[];
}
const props = withDefaults(defineProps<LayCheckboxGroupProps>(), {
modelValue: () => [],
});
const emit = defineEmits(["update:modelValue", "change"]);
const modelValue = ref(props.modelValue);
provide("checkboxGroup", { name: "LayCheckboxGroup", modelValue: modelValue });
watch(
() => modelValue,
(val) => {
emit("change", modelValue.value);
emit("update:modelValue", modelValue.value);
},
{ deep: true }
);
watch(
() => props.modelValue,
(val) => (modelValue.value = val)
);
</script>