1e41f4b71Sopenharmony_ci# ContentSlot 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci用于渲染并管理Native层使用C-API创建的组件。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci支持混合模式开发,当容器是ArkTS组件,子组件在Native侧创建时,推荐使用ContentSlot占位组件。 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci> **说明:** 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> 本模块首批接口从API version 12开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## 接口 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciContentSlot(content: Content) 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci当内容添加到占位符组件时调用。 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**参数:** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 参数描述 | 24e41f4b71Sopenharmony_ci| ------- | -------- | ---- | ------------------------------------------------------------ | 25e41f4b71Sopenharmony_ci| content | [Content](../js-apis-arkui-Content.md) | 是 | Content作为ContentSlot的管理器,通过Native侧提供的接口,可以注册并触发ContentSlot的上下树事件回调以及管理ContentSlot的子组件。 | 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**示例:** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci```ts 30e41f4b71Sopenharmony_ciimport { nativeNode } from 'libNativeNode.so' // 开发者自己实现的so 31e41f4b71Sopenharmony_ciimport { NodeContent } from '@kit.ArkUI' 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci@Entry 34e41f4b71Sopenharmony_ci@Component 35e41f4b71Sopenharmony_cistruct Parent { 36e41f4b71Sopenharmony_ci private nodeContent: Content = new NodeContent(); 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci aboutToAppear() { 39e41f4b71Sopenharmony_ci // 通过C-API创建节点,并添加到管理器nodeContent上 40e41f4b71Sopenharmony_ci nativeNode.createNativeNode(this.nodeContent); 41e41f4b71Sopenharmony_ci } 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci build() { 44e41f4b71Sopenharmony_ci Column() { 45e41f4b71Sopenharmony_ci // 显示nodeContent管理器里存放的Native侧的组件 46e41f4b71Sopenharmony_ci ContentSlot(this.nodeContent) 47e41f4b71Sopenharmony_ci } 48e41f4b71Sopenharmony_ci } 49e41f4b71Sopenharmony_ci} 50e41f4b71Sopenharmony_ci``` 51