文件最后提交记录最后更新时间
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
add JSVMAPI Signed-off-by: jiang-qunchao <jiangqunchao@huawei.com> 1 个月前
README.md

ArkTs使用JSVM-API接口进行primitive类相关开发

介绍

在使用JSVM-API接口时,开发人员可以实现在JSVM模块中与JavaScript对象的交互,并进行数据转换和获取特定对象的操作,它们在不同的场景中发挥着重要的作用,使开发人员能够更灵活地处理JavaScript值和对象。

该工程中展示的代码详细描述可查如下链接:

效果预览

首页 执行及结果即时反馈

使用说明

  1. 在主界面,可以点击Hello World,开始执行。
  2. 执行结果会即时反馈在屏幕中央,并在控制台打印log。

工程目录

coercetobool/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        // 自动化测试代码
coercetonumber/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libcoercetonumber
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关联
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接口
 │   ├── ets
 │   │   ├── coercetonumberability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
coercetoobject/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libcoercetoobject
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── coercetoobjectability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
coercetostring/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libcoercetostring
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── coercetostringability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
getboolean/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libgetboolean
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── getbooleanability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
getglobal/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libgetglobal
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── getglobalability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
getnull/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libgetnull
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── getnullability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
getundefined/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libgetundefined
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── getundefinedability
 │   │   ├── pages
 │   │       ├── Index.ets               // ArkTS侧调用C/C++方法实现
 │   ├── module.json5
 │   └── resources
 ├── ohosTest
 │   ├── ets
 │   │   ├── test
 │   │       ├── Ability.test.ets        // 自动化测试代码
getvaluebool/src/
 ├── main
 │   ├── cpp
 │   │   ├── types
 │   │   │   ├── libgetvaluebool
 │   │   │   │   ├── Index.d.ts          // 提供JS侧的接口方法
 │   │   │   │   ├── oh-package.json5 	 // 将index.d.ts与cpp文件关
 │   │   ├── CMakeLists.txt              // 配置CMake打包参数
 │   │   ├── hello.cpp                   // 实现Native侧的runTest接
 │   ├── ets
 │   │   ├── getvalueboolability
 │   │   ├── 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/JsvmAboutPrimitive > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master