# ArkTS使用JSVM-API接口进行array相关开发
### 介绍
使用 JSVM-API 接口进行数组(array)相关开发时,调用相关接口可以在 JSVM 模块中直接操作和处理 JavaScript 中的数组。
该工程中展示的代码详细描述可查如下链接:
- [使用JSVM-API接口进行array相关开发](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-array.md)
### 效果预览
| 首页 | 执行及结果即时反馈 |
| :----------------------------------------------------------------: | :----------------------------------------------------------------: |
|
|
|
### 使用说明
1. 在主界面,可以点击Hello World,开始执行。
2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。
### 工程目录
```
createarray/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libentry
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接口
│ ├── ets
│ │ ├── entryability
│ │ ├── entrybackupability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
createarraywithlength/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libcreatearraywithlength
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接口
│ ├── ets
│ │ ├── createarraywithlengthability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
createdataview/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libcreatedataview
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── createdataviewability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
createtypedarray/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libcreatetypedarray
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── createtypedarrayability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
deleteelement/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libdeleteelement
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── deleteelementability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
getarraylength/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libgetarraylength
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── getarraylengthability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
getdataviewinfo/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libgetdataviewinfo
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── getdataviewinfoability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
getelement/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libgetelement
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── getelementability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
gettypedarrayinfo/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libgettypedarrayinfo
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── gettypedarrayinfoability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
haselement/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libhaselement
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── haselementability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
isarray/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libisarray
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── isarrayability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
isdataview/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libisdataview
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── isdataviewability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
istypedarray/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libistypedarray
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── istypedarrayability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
setelement/src/
├── main
│ ├── cpp
│ │ ├── types
│ │ │ ├── libsetelement
│ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法
│ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关
│ │ ├── CMakeLists.txt // 配置CMake打包参数
│ │ ├── hello.cpp // 实现Native侧的runTest接
│ ├── ets
│ │ ├── setelementability
│ │ ├── pages
│ │ ├── Index.ets // ArkTS侧调用C/C++方法实现
│ ├── module.json5
│ └── resources
├── ohosTest
│ ├── ets
│ │ ├── test
│ │ ├── Ability.test.ets // 自动化测试代码
```
### 相关权限
不涉及。
### 依赖
不涉及。
### 约束与限制
1.本示例仅支持标准系统上运行, 支持设备:Phone。
2.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。
3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。
### 下载
如需单独下载本工程,执行如下命令:
```
git init
git config core.sparsecheckout true
echo code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutArray > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master
```