可以将需要的模块打成har包,然后将har包作为模块,集成到项目中。一、打包flutter模块:1、创建flutter子模块工程:flutter create -t module my_flutter_module 2、编译生成 flutter\_module.har:cd my_flutter_module flutter build har --local-engine=/Users/xxx/ohos/src/out/ohos_debug_unopt_arm64 --debug 3、复制EntryAbility.ets和Index.ets到HarmonyOS项目MyApplication中:cp my_flutter_module/.ohos/entry/src/main/ets/entryability/EntryAbility.ets MyApplication/entry/src/main/ets/entryability/EntryAbility.ets cp my_flutter_module/.ohos/entry/src/main/ets/pages/Index.ets MyApplication/entry/src/main/ets/pages/Index.ets 二、在HarmonyOS工程中引用har包:1、复制flutter\_module.har到HarmonyOS项目MyApplication:cp my_flutter_module/.ohos/flutter_module/build/default/outputs/default/flutter_module.har MyApplication/har/flutter_module.har 2、修改MyApplication/entry/oh-package.json5:{ // ... "dependencies": { "@ohos/flutter_module": "../har/flutter_module.har" } }3、使用Deveco Studio配置MyApplication的签名。4、运行MyApplication。更多har包的详细使用请参考官网文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/har-package-V5
可以将需要的模块打成har包,然后将har包作为模块,集成到项目中。
一、打包flutter模块:
1、创建flutter子模块工程:
2、编译生成 flutter\_module.har:
3、复制EntryAbility.ets和Index.ets到HarmonyOS项目MyApplication中:
二、在HarmonyOS工程中引用har包:
1、复制flutter\_module.har到HarmonyOS项目MyApplication:
2、修改MyApplication/entry/oh-package.json5:
3、使用Deveco Studio配置MyApplication的签名。
4、运行MyApplication。
更多har包的详细使用请参考官网文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/har-package-V5