From 1b8db5b7f1ddb7ae325a0e6531e82b96253137df Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 12 Jan 2025 18:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20FormRender=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=B8=B2=E6=9F=93=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=AF=B9=E6=8F=92=E6=A7=BD=E5=92=8C=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/render/FormRender.vue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/render/FormRender.vue b/src/components/render/FormRender.vue index 7cde9579..7c1056c1 100644 --- a/src/components/render/FormRender.vue +++ b/src/components/render/FormRender.vue @@ -80,14 +80,15 @@ const renderComponent = (config: any, model: any, slotScope: any = {}) => { // 动态插槽解析 const slotNodes: Record = {} for (const [slotName, slotContent] of Object.entries(slots)) { - slotNodes[slotName] = (slotScopeData: any) => renderSlotContent(slotContent, model, slotScopeData) + slotNodes[slotName] = (slotScopeData: any) => + renderSlotContent(slotContent, model, { ...slotScope, ...slotScopeData }) } // 渲染组件内容 const renderContent = () => { // 如果配置了 `html`,直接渲染为 HTML 内容 if (html) { - return h('div', { innerHTML: typeof html === 'string' ? html : model[html] }) + return h(Component, { innerHTML: typeof html === 'string' ? html : model[html] }) } // 如果配置了 `text`,直接渲染为文本内容 @@ -97,7 +98,7 @@ const renderComponent = (config: any, model: any, slotScope: any = {}) => { // 如果配置了 `content`,递归渲染子组件 if (Array.isArray(content)) { - return content.map((childConfig: any) => renderComponent(childConfig, model)) + return content.map((childConfig: any) => renderComponent(childConfig, model, slotScope)) } return null @@ -106,14 +107,11 @@ const renderComponent = (config: any, model: any, slotScope: any = {}) => { // 渲染组件 return h(Component, parsedProps, { ...slotNodes, - default: renderContent, // 确保默认插槽只包含当前组件的内容 + default: renderContent, }) }