layui/.svn/pristine/15/153dd6eff0e72257ed34eb17b37d80287beb007f.svn-base
2022-12-09 16:41:41 +08:00

47 lines
928 B
Plaintext

<script lang="ts">
export default {
name: "LayCollapse",
};
</script>
<script setup lang="ts">
import "./index.less";
import { withDefaults, provide, ref, watch } from "vue";
export interface CollapseProps {
accordion?: boolean;
modelValue?: number | string | number[] | string[];
collapseTransition?: boolean;
}
const props = withDefaults(defineProps<CollapseProps>(), {
modelValue: () => [],
accordion: false,
collapseTransition: true,
});
watch(
() => props.modelValue,
(val) => {
activeValues.value = ([] as any[]).concat(val);
}
);
const emit = defineEmits(["update:modelValue", "change"]);
const activeValues = ref<Array<any>>(([] as any[]).concat(props.modelValue));
provide("layCollapse", {
accordion: props.accordion,
collapseTransition: props.collapseTransition,
activeValues,
emit,
});
</script>
<template>
<div class="layui-collapse">
<slot></slot>
</div>
</template>