- Taro跨端框架
支持React语法开发鸿蒙应用,架构分为三层:
- ArkVM层运行业务代码和React核心
- TaroElement树处理节点创建和属性绑定
- TaroRenderNode虚拟节点树与上屏节点一一对应
import { Component } from '@tarojs/taro'
export default class MyComponent extends Component {render() {return (<div onClick={this.handleClick}><text>Hello Taro on HarmonyOS</text></div>)}
}
需配置build-profile.json5声明动态路由!!!
2.Yoga布局引擎
Facebook跨平台布局方案,兼容Flexbox!!!
{System.loadLibrary("yoga");System.loadLibrary("yogacore");
}
Button btn = (Button) findComponentById(ResourceTable.Id_btn);
btn.setLayoutConfig(new YogaLayoutConfig()); // 应用Yoga布局
3.Axios网络库
适配OpenHarmony的Promise风格HTTP客户端:
import axios from '@ohos/axios'
axios.get('/user?ID=123').then(res => console.log(res.data)).catch(err => console.error(err)); // 支持拦截器自动JSON转换
4.HDF驱动框架
设备驱动开发标准结构:
HdfDriverEntry g_deviceSample = {.Bind = SampleDriverBind, // 设备绑定.Init = SampleDriverInit, // 驱动初始化.Release = SampleDriverRelease // 资源释放
};
完整集成需在module.json5配置依赖,建议参考华为官方示例仓。