| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 3 个月前 | ||
| 28 天前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 6 个月前 | ||
| 1 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 28 天前 | ||
| 8 个月前 |
ArkTS使用Node-API进行string相关开发
介绍
使用Node-API关于string的八个接口,可以让Node-API模块和ArkTS字符串进行交互,本工程中展示的代码详细描述可查如下链接中业务扩展场景介绍部分。
效果预览
| 首页 | 执行结果图 |
|---|---|
![]() |
![]() |
使用说明
- 运行Index主界面。
- 页面呈现上述首页效果,分别点击ListItem组件可以执行对应文本内容的Node-API接口并将文本Result:改为执行成功结果,然后在控制台中打印出对应日志。
- 运行测试用例NodeApiString.test.ets文件对页面代码进行测试可以全部通过。
工程目录
entry/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ ├── Index.d.ts
│ │ ├── oh-package.json5
│ │ ├── CMakeLists.txt
│ │ ├── napi_init.cpp
│ ├── ets
│ │ ├── entryability
│ │ ├── entrybackupability
│ │ ├── pages
│ │ ├── Index.ets // 使用Node-API进行string相关开发示例代码
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ └── test
│ │ ├── Ability.test.ets
│ │ ├── NodeApiString.test.ets // 自动化测试代码
│ │ └── List.test.ets
相关权限
不涉及。
依赖
不涉及。
约束与限制
1.本示例仅支持标准系统上运行, 支持设备:RK3568。
2.本示例为Stage模型,支持API22版本SDK。
3.本示例需要使用DevEco Studio 6.0.0 Release (Build Version: 6.0.0.858, built on October 21, 2025)及以上版本才可编译运行。
下载
如需单独下载本工程,执行如下命令:
git init
git config core.sparsecheckout true
echo code/DocsSample/ArkTS/NodeAPI/NodeAPIUse/NodeAPIString > .git/info/sparse-checkout
git remote add origin https://gitcode.com/openharmony/applications_app_samples.git
git pull origin master

