feat: 插件页面支持slot

This commit is contained in:
jxxghp
2024-04-17 22:55:45 +08:00
parent 6350c7e9e6
commit 9ff212c94d
+11
View File
@@ -7,6 +7,7 @@ interface RenderProps {
text: string text: string
html: string html: string
content?: any content?: any
slots?: any
props?: any props?: any
} }
@@ -22,6 +23,7 @@ const formItem = ref<RenderProps>(elementProps.config ?? {
html: '', html: '',
props: {}, props: {},
content: [], content: [],
slots: {},
}) })
</script> </script>
@@ -32,6 +34,15 @@ const formItem = ref<RenderProps>(elementProps.config ?? {
v-bind="formItem.props" v-bind="formItem.props"
> >
{{ formItem.text }} {{ formItem.text }}
<template v-for="(content, name) in (formItem.slots || [])" :key="name" v-slot:[name]="{_props}">
<slot :name="name" v-bind="_props">
<PageRender
v-for="(slotItem, slotIndex) in (content || [])"
:key="slotIndex"
:config="slotItem"
/>
</slot>
</template>
<PageRender <PageRender
v-for="(innerItem, innerIndex) in (formItem.content || [])" v-for="(innerItem, innerIndex) in (formItem.content || [])"
:key="innerIndex" :key="innerIndex"