# NAPI_Learning **Repository Path**: hw_cb/NAPI_Learning ## Basic Information - **Project Name**: NAPI_Learning - **Description**: NAPI使用循序渐进,学习。 可直接导入工程,在手机/开发板中运行 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: easy_branch - **Homepage**: https://gitee.com/flyingfishercn/NAPI_Learning/blob/easy_branch/README.md - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2023-05-08 - **Last Updated**: 2023-05-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NAPI-Learning ## 1.介绍 两个示例界面主要介绍NAPI在鸿蒙中的使用(easy_branch分支), master废弃。讲述常用的ArkTS可能涉及场景 ### 1.1 entry Module ![输入图片说明](private_custom/resources/%E6%A0%B7%E4%BE%8B%E7%95%8C%E9%9D%A21.jpg) #### 1.1.1 同步操作 add(3+2) sub(3-2) hyPotC(3,2) 3和2平方和取根 addsync(10+2) #### 1.1.2 异步操作 addAsyncByPromise(3+2) getAsyncByCallback(3+2) #### 1.1.3 C++子线程调用JS对象方法 示例两种 #### 1.1.4 C++类绑定 类绑定例子,通过NAPI绑定,实现JS对象与C++对象进行绑定,调用对象上定义的方法。JS与C++的class主要通过napi_wrap实现 #### 1.1.5 页面声明周期处理举例 ArkTS页面生命周期aboutToAppear, aboutToDisappear监听演示举例 ### 1.2 NativeSample ![输入图片说明](private_custom/resources/%E6%A0%B7%E4%BE%8B%E7%95%8C%E9%9D%A22.jpg) 演示三方库加载相关内容 #### 1.2.1 native侧加载 方法一:cmake依赖 方法二:dlopen加载 备注:so库编译详见文件private_custom/compileSo/README.md #### 1.2.2 ets应用侧加载 为1.2.1中“camke依赖”的精简版,利用camke生成的库 1)将库预制到libs/arm64-v8a 和 libs/armeabi-v7a目录下 2)直接将src/main/cpp目录下的cpp相关文件删除,包括index.etx也可以选择删除 编译应用直接运行即可 ## 2.软件架构 软件架构说明 ## 3.安装教程 1. xxxx 2. xxxx 3. xxxx ## 4.使用说明 1. xxxx 2. xxxx 3. xxxx ## 5.参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request ## 6.特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)