Runtime API / Method

NodeScriptComponentApi.create

从 owning Artifact export 或精确外部引用创建 parent-owned 组件。

使用说明

字符串只解析当前 owning Artifact 的 export 及其完整 definition closure;跨 Artifact 创建必须传完整的 FlamoComponentRefV1,并通过 revision、hash、Runtime ABI 与 component ABI 校验。

const badge = await ctx.components.create('Badge', {
parent: ctx.scene.root,
props: { label: 'New' },
placement: { kind: 'append' },
key: 'dynamic-badge',
signal,
});

准备、挂载或初始化失败时会回滚,不留下半挂载 entity。一个 owner 最多保留 1000 个动态 child。

参数

componentstring | { ... }
optionsComponentCreateOptions