fix update slot fail
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Comment, Fragment, Teleport, defineComponent, h, isVNode, onBeforeUpdate, useSlots } from "vue";
|
import { Comment, Fragment, Teleport, defineComponent, h, isVNode, useSlots } from "vue";
|
||||||
import type { CSSProperties, PropType, VNode, VNodeChild } from "vue";
|
import type { CSSProperties, PropType, VNode, VNodeChild } from "vue";
|
||||||
import type { SpaceProps, SpaceSlots, SpaceSize } from "./type";
|
import type { SpaceProps, SpaceSlots, SpaceSize } from "./type";
|
||||||
|
|
||||||
@@ -76,15 +76,9 @@ const props = defineProps({
|
|||||||
|
|
||||||
const slots = useSlots() as SpaceSlots;
|
const slots = useSlots() as SpaceSlots;
|
||||||
|
|
||||||
let children = flattenChildren(slots.default?.() ?? []);
|
const children = computed(() => flattenChildren(slots.default?.() ?? []));
|
||||||
let separatorContent = resolveSeparatorContent();
|
const separatorContent = computed(() => resolveSeparatorContent());
|
||||||
let hasSeparator = hasSeparatorContent(separatorContent);
|
const hasSeparator = computed(() => hasSeparatorContent(separatorContent.value));
|
||||||
|
|
||||||
onBeforeUpdate(() => {
|
|
||||||
children = flattenChildren(slots.default?.() ?? []);
|
|
||||||
separatorContent = resolveSeparatorContent();
|
|
||||||
hasSeparator = hasSeparatorContent(separatorContent);
|
|
||||||
});
|
|
||||||
|
|
||||||
function resolveSeparatorContent(): VNodeChild | undefined {
|
function resolveSeparatorContent(): VNodeChild | undefined {
|
||||||
if (props.separator !== undefined) {
|
if (props.separator !== undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user