• Home
Name Date Size #Lines LOC

..--

AppScope/06-May-2025-3532

entry/06-May-2025-855713

hvigor/06-May-2025-3836

screenshots/06-May-2025-

.gitignoreD06-May-2025133 1212

README.mdD06-May-20252.7 KiB7555

build-profile.json5D06-May-20251.4 KiB5857

code-linter.json5D06-May-2025958 3534

hvigorfile.tsD06-May-2025843 225

oh-package.json5D06-May-2025834 2624

ohosTest.mdD06-May-20251.1 KiB97

README.md

1# ArkTS使用Node-API接口在主线程中进行模块加载
2
3### 介绍
4
5本工程展示了使用Node-API接口在主线程中进行系统模块加载与ArkTS单文件加载。详细描述可查如下链接中。
6
7- [使用Node-API接口在主线程中进行模块加载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-napi-load-module.md)
8
9### 效果预览
10
11| 首页                                                         | 执行结果图                                                   |
12| ------------------------------------------------------------ | ------------------------------------------------------------ |
13| <img src="./screenshots/NodeApiLoadModule1.png" style="zoom: 67%;" /> | <img src="./screenshots/NodeApiLoadModule2.png" style="zoom: 67%;" /> |
14
15### 使用说明
16
171. 运行Index主界面。
182. 页面呈现如上图效果和两个按钮,依次点击按钮后可以加载系统模块和单文件模块,并将成功结果呈现到text文本中。
193. 运行测试用例NodeApiLoadModule.test.ets文件对页面代码进行测试可以全部通过。
20
21### 工程目录
22
23```
24entry/src/
25 ├── main
26 │   ├── cpp
27 │   │   ├── types
28 │   │       ├── libentry
29 │   │       └── libentry1
30 │   │   ├── file.cpp                    // ArkTS单文件加载
31 │   │   ├── CMakeLists.txt
32 │   │   ├── napi_init.cpp               // 系统模块加载
33 │   ├── ets
34 │   │   ├── entryability
35 │   │   ├── entrybackupability
36 │   │   ├── pages
37 │   │       ├── Index.ets               // 加载模块
38 │   │   ├── Test.ets
39 │   ├── module.json5
40 │   └── resources
41 ├── ohosTest
42 │   ├── ets
43 │   │   └── test
44 │   │       ├── Ability.test.ets
45 │   │       ├── NodeApiLoadModule.test.ets  // 自动化测试代码
46 │   │       └── List.test.ets
47```
48
49### 相关权限
50
51不涉及。
52
53### 依赖
54
55不涉及。
56
57### 约束与限制
58
591.本示例仅支持标准系统上运行, 支持设备:RK3568。
60
612.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.58。
62
633.本示例需要使用DevEco Studio 5.0.1 Release (Build Version: 5.0.5.306, built on December 6, 2024)及以上版本才可编译运行。
64
65### 下载
66
67如需单独下载本工程,执行如下命令:
68
69````
70git init
71git config core.sparsecheckout true
72echo code/DocsSample/ArkTs/NodeAPI/NodeApiClassicUseCases/NodeApiLoadModule > .git/info/sparse-checkout
73git remote add origin https://gitee.com/openharmony/applications_app_samples.git
74git pull origin master
75````