diff --git a/packages/demo/public/assets.json b/packages/demo/public/assets.json index ae741151a..90c43755a 100644 --- a/packages/demo/public/assets.json +++ b/packages/demo/public/assets.json @@ -13425,15 +13425,7 @@ "props": { "href": "https://fusion.design", "target": "_blank", - "children": { - "type": "JSSlot", - "value": { - "componentName": "Typography.Text", - "props": { - "children": "这是一个超链接" - } - } - } + "children": "这是一个超链接" } } } diff --git a/packages/utils/src/build-components.ts b/packages/utils/src/build-components.ts index 10fef43d0..7dfeed3bc 100644 --- a/packages/utils/src/build-components.ts +++ b/packages/utils/src/build-components.ts @@ -1,5 +1,5 @@ -import { ComponentType } from 'react'; -import { NpmInfo} from '@ali/lowcode-types'; +import { ComponentType, forwardRef, createElement } from 'react'; +import { NpmInfo } from '@ali/lowcode-types'; import { isReactComponent } from './is-react'; import { isESModule } from './is-es-module'; @@ -11,8 +11,16 @@ function accessLibrary(library: string | object) { if (typeof library !== 'string') { return library; } + + return (window as any)[library] || generateHtmlComp(library); +} - return (window as any)[library] || library; +export function generateHtmlComp(library: string) { + if (['a', 'img', 'div', 'span', 'svg'].includes(library)) { + return forwardRef((props, ref) => { + return createElement(library, { ref, ...props }, props.children); + }); + } } export function getSubComponent(library: any, paths: string[]) {