mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 04:40:32 +00:00
支持原生 HTML 标签作为组件
This commit is contained in:
parent
05f4103cda
commit
a3015961ed
@ -13425,15 +13425,7 @@
|
||||
"props": {
|
||||
"href": "https://fusion.design",
|
||||
"target": "_blank",
|
||||
"children": {
|
||||
"type": "JSSlot",
|
||||
"value": {
|
||||
"componentName": "Typography.Text",
|
||||
"props": {
|
||||
"children": "这是一个超链接"
|
||||
}
|
||||
}
|
||||
}
|
||||
"children": "这是一个超链接"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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[]) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user