【HarmonyOS NEXT应用开发】案例65:Fabric 自定义组件开发指导

1.编写 RN 调用 Fabric 组件的代码

编写MarqueeViewNativeComponent.tsx,注意,如果要使用 Codegen ,文件必须以NativeComponent命名。在文件中使用 codegenNativeComponent 创建 MarqueeView 组件,其中 MarqueeViewProps 里声明了 src 属性和 onStop 事件:

type OnStopEventData = Readonly<{

isStop: boolean

}>;



interface MarqueeViewProps extends ViewProps {

src: string,

onStop?: DirectEventHandler;

}



const MarqueeView = codegenNativeComponent(

'MarqueeView'

) as HostComponent;

和其他标准组件的创建方式一样,在组件容器内添加 MarqueeView 标签:


你可能感兴趣的:(c语言,c++,开发语言,华为,harmonyos,华为云,华为od)