diff --git a/packages/react/src/runtime/index.tsx b/packages/react/src/runtime/index.tsx index 01687f362..6d4c09559 100644 --- a/packages/react/src/runtime/index.tsx +++ b/packages/react/src/runtime/index.tsx @@ -86,6 +86,9 @@ export interface IIconConfig { innerFillColor: string; }; }; + + // 唯一ID 生成函数 + guid?: () => string, } // 图标基础属性 @@ -232,7 +235,10 @@ export function IconWrapper(name: string, rtl: boolean, render: IconRender): Ico const ICON_CONFIGS = useContext(IconContext); - const id = useMemo(guid, []); + let id = guid(); + if (ICON_CONFIGS.guid && typeof ICON_CONFIGS.guid == 'function') { + id = ICON_CONFIGS.guid(); + } const svgProps = IconConverter(id, { size, diff --git a/packages/vue-next/src/runtime/index.tsx b/packages/vue-next/src/runtime/index.tsx index 59fcc47c0..13f27c4e3 100644 --- a/packages/vue-next/src/runtime/index.tsx +++ b/packages/vue-next/src/runtime/index.tsx @@ -85,6 +85,9 @@ export interface IIconConfig { innerFillColor: string; }; }; + + // 唯一ID 生成函数 + guid?: () => string, } // 图标基础属性 @@ -218,10 +221,13 @@ export function IconWrapper(name: string, rtl: boolean, render: IconRender): Ico props: ['size', 'strokeWidth', 'strokeLinecap', 'strokeLinejoin', 'theme', 'fill', 'spin'], setup: (props) => { - const id = guid(); - const ICON_CONFIGS = inject(IconContext, DEFAULT_ICON_CONFIGS); + let id = guid(); + if (ICON_CONFIGS.guid && typeof ICON_CONFIGS.guid == 'function') { + id = ICON_CONFIGS.guid(); + } + return () => { const {