Runtime API / Method

NodeScriptComponentApi.createBatch

批量创建最多 100 个组件,并在任一失败时逆序回滚。

使用说明

批量级 AbortSignal 应用于全部请求,单个 request 自己的 signal 优先。任何请求失败时,已经创建的实例会按逆序销毁,调用方不会观察到部分成功的结果。

const handles = await ctx.components.createBatch([
{ component: 'Avatar', props: { userId: 'a' } },
{ component: 'Avatar', props: { userId: 'b' } },
], { signal });

参数

requestsreadonly ComponentCreateRequest[]
options{ ... }