修复 src 结构
This commit is contained in:
9
src/component/collapse/index.ts
Normal file
9
src/component/collapse/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { App } from "vue";
|
||||
import Component from "./index.vue";
|
||||
import type { IDefineComponent } from "../type/index";
|
||||
|
||||
Component.install = (app: App) => {
|
||||
app.component(Component.name || "LayCollapse", Component);
|
||||
};
|
||||
|
||||
export default Component as IDefineComponent;
|
||||
45
src/component/collapse/index.vue
Normal file
45
src/component/collapse/index.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="layui-collapse">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="LayCollapse"></script>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
withDefaults,
|
||||
defineProps,
|
||||
provide,
|
||||
ref,
|
||||
defineEmits,
|
||||
watch,
|
||||
} from "vue";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: number | string | [];
|
||||
accordion?: boolean;
|
||||
}>(),
|
||||
{
|
||||
modelValue: () => [],
|
||||
accordion: false,
|
||||
}
|
||||
);
|
||||
|
||||
// 监听传入的值
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val, oldVal) => {
|
||||
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,
|
||||
activeValues,
|
||||
emit,
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user