| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 22-Oct-2025 | - | 35 | 32 | ||
| defineproperties/ | 22-Oct-2025 | - | 720 | 587 | ||
| deleteproperty/ | 22-Oct-2025 | - | 635 | 521 | ||
| getallpropertynames/ | 22-Oct-2025 | - | 629 | 516 | ||
| getnamedproperty/ | 22-Oct-2025 | - | 631 | 517 | ||
| getproperty/ | 22-Oct-2025 | - | 626 | 513 | ||
| getpropertynames/ | 22-Oct-2025 | - | 687 | 573 | ||
| hasnamedproperty/ | 22-Oct-2025 | - | 637 | 522 | ||
| hasownproperty/ | 22-Oct-2025 | - | 647 | 531 | ||
| hasproperty/ | 22-Oct-2025 | - | 633 | 519 | ||
| hvigor/ | 22-Oct-2025 | - | 38 | 36 | ||
| screenshots/ | 22-Oct-2025 | - | ||||
| setnamedproperty/ | 22-Oct-2025 | - | 640 | 523 | ||
| setproperty/ | 22-Oct-2025 | - | 636 | 522 | ||
| .gitignore | D | 22-Oct-2025 | 144 | 12 | 12 | |
| README.md | D | 22-Oct-2025 | 11.2 KiB | 264 | 242 | |
| build-profile.json5 | D | 22-Oct-2025 | 3.7 KiB | 178 | 176 | |
| code-linter.json5 | D | 22-Oct-2025 | 992 | 35 | 34 | |
| hvigorfile.ts | D | 22-Oct-2025 | 864 | 22 | 5 | |
| oh-package.json5 | D | 22-Oct-2025 | 834 | 26 | 24 | |
| ohosTest.md | D | 22-Oct-2025 | 2.6 KiB | 19 | 16 |
README.md
1# ArkTs使用JSVM-API接口设置JavaScript对象的属性 2 3### 介绍 4 5使用JSVM-API接口获取和设置JavaScript对象的属性。通过合理使用这些函数,实现更复杂的功能和逻辑。 6 7该工程中展示的代码详细描述可查如下链接: 8 9- [使用JSVM-API接口设置JavaScript对象的属性](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/napi/use-jsvm-about-property.md) 10 11### 效果预览 12 13| 首页 | 执行及结果即时反馈 | 14| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | 15| <img src="./screenshots/JsvmAboutProperty_1.png" style="zoom:33%;" /> | <img src="./screenshots/JsvmAboutProperty_2.png" style="zoom:33%;" /> | 16 17### 使用说明 18 191. 在主界面,可以点击Hello World,开始执行。 202. 执行结果会即时反馈在屏幕中央,并在控制台打印log。 21 22### 工程目录 23 24``` 25defineproperties/src/ 26 ├── main 27 │ ├── cpp 28 │ │ ├── types 29 │ │ │ ├── libdefineproperties 30 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 31 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 32 │ │ ├── CMakeLists.txt // 配置CMake打包参数 33 │ │ ├── hello.cpp // 实现Native侧的runTest接口 34 │ ├── ets 35 │ │ ├── definepropertiesability 36 │ │ ├── pages 37 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 38 │ ├── module.json5 39 │ └── resources 40 ├── ohosTest 41 │ ├── ets 42 │ │ ├── test 43 │ │ ├── Ability.test.ets // 自动化测试代码 44deleteproperty/src/ 45 ├── main 46 │ ├── cpp 47 │ │ ├── types 48 │ │ │ ├── libdeleteproperty 49 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 50 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关联 51 │ │ ├── CMakeLists.txt // 配置CMake打包参数 52 │ │ ├── hello.cpp // 实现Native侧的runTest接口 53 │ ├── ets 54 │ │ ├── deletepropertyability 55 │ │ ├── pages 56 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 57 │ ├── module.json5 58 │ └── resources 59 ├── ohosTest 60 │ ├── ets 61 │ │ ├── test 62 │ │ ├── Ability.test.ets // 自动化测试代码 63getallpropertynames/src/ 64 ├── main 65 │ ├── cpp 66 │ │ ├── types 67 │ │ │ ├── libgetallpropertynames 68 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 69 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 70 │ │ ├── CMakeLists.txt // 配置CMake打包参数 71 │ │ ├── hello.cpp // 实现Native侧的runTest接 72 │ ├── ets 73 │ │ ├── getallpropertynamesability 74 │ │ ├── pages 75 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 76 │ ├── module.json5 77 │ └── resources 78 ├── ohosTest 79 │ ├── ets 80 │ │ ├── test 81 │ │ ├── Ability.test.ets // 自动化测试代码 82getnamedproperty/src/ 83 ├── main 84 │ ├── cpp 85 │ │ ├── types 86 │ │ │ ├── libgetnamedproperty 87 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 88 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 89 │ │ ├── CMakeLists.txt // 配置CMake打包参数 90 │ │ ├── hello.cpp // 实现Native侧的runTest接 91 │ ├── ets 92 │ │ ├── getnamedpropertyability 93 │ │ ├── pages 94 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 95 │ ├── module.json5 96 │ └── resources 97 ├── ohosTest 98 │ ├── ets 99 │ │ ├── test 100 │ │ ├── Ability.test.ets // 自动化测试代码 101getproperty/src/ 102 ├── main 103 │ ├── cpp 104 │ │ ├── types 105 │ │ │ ├── libgetproperty 106 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 107 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 108 │ │ ├── CMakeLists.txt // 配置CMake打包参数 109 │ │ ├── hello.cpp // 实现Native侧的runTest接 110 │ ├── ets 111 │ │ ├── getpropertyability 112 │ │ ├── pages 113 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 114 │ ├── module.json5 115 │ └── resources 116 ├── ohosTest 117 │ ├── ets 118 │ │ ├── test 119 │ │ ├── Ability.test.ets // 自动化测试代码 120getpropertynames/src/ 121 ├── main 122 │ ├── cpp 123 │ │ ├── types 124 │ │ │ ├── libentry 125 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 126 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 127 │ │ ├── CMakeLists.txt // 配置CMake打包参数 128 │ │ ├── hello.cpp // 实现Native侧的runTest接 129 │ ├── ets 130 │ │ ├── entryability 131 │ │ ├── entrybackupability 132 │ │ ├── pages 133 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 134 │ ├── module.json5 135 │ └── resources 136 ├── ohosTest 137 │ ├── ets 138 │ │ ├── test 139 │ │ ├── Ability.test.ets // 自动化测试代码 140hasnamedproperty/src/ 141 ├── main 142 │ ├── cpp 143 │ │ ├── types 144 │ │ │ ├── libhasnamedproperty 145 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 146 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 147 │ │ ├── CMakeLists.txt // 配置CMake打包参数 148 │ │ ├── hello.cpp // 实现Native侧的runTest接 149 │ ├── ets 150 │ │ ├── hasnamedpropertyability 151 │ │ ├── pages 152 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 153 │ ├── module.json5 154 │ └── resources 155 ├── ohosTest 156 │ ├── ets 157 │ │ ├── test 158 │ │ ├── Ability.test.ets // 自动化测试代码 159hasownproperty/src/ 160 ├── main 161 │ ├── cpp 162 │ │ ├── types 163 │ │ │ ├── libhasownproperty 164 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 165 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 166 │ │ ├── CMakeLists.txt // 配置CMake打包参数 167 │ │ ├── hello.cpp // 实现Native侧的runTest接 168 │ ├── ets 169 │ │ ├── hasownpropertyability 170 │ │ ├── pages 171 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 172 │ ├── module.json5 173 │ └── resources 174 ├── ohosTest 175 │ ├── ets 176 │ │ ├── test 177 │ │ ├── Ability.test.ets // 自动化测试代码 178hasproperty/src/ 179 ├── main 180 │ ├── cpp 181 │ │ ├── types 182 │ │ │ ├── libhasproperty 183 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 184 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 185 │ │ ├── CMakeLists.txt // 配置CMake打包参数 186 │ │ ├── hello.cpp // 实现Native侧的runTest接 187 │ ├── ets 188 │ │ ├── haspropertyability 189 │ │ ├── pages 190 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 191 │ ├── module.json5 192 │ └── resources 193 ├── ohosTest 194 │ ├── ets 195 │ │ ├── test 196 │ │ ├── Ability.test.ets // 自动化测试代码 197setnamedproperty/src/ 198 ├── main 199 │ ├── cpp 200 │ │ ├── types 201 │ │ │ ├── libsetnamedproperty 202 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 203 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 204 │ │ ├── CMakeLists.txt // 配置CMake打包参数 205 │ │ ├── hello.cpp // 实现Native侧的runTest接 206 │ ├── ets 207 │ │ ├── setnamedpropertyability 208 │ │ ├── pages 209 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 210 │ ├── module.json5 211 │ └── resources 212 ├── ohosTest 213 │ ├── ets 214 │ │ ├── test 215 │ │ ├── Ability.test.ets // 自动化测试代码 216setproperty/src/ 217 ├── main 218 │ ├── cpp 219 │ │ ├── types 220 │ │ │ ├── libsetproperty 221 │ │ │ │ ├── Index.d.ts // 提供JS侧的接口方法 222 │ │ │ │ ├── oh-package.json5 // 将index.d.ts与cpp文件关 223 │ │ ├── CMakeLists.txt // 配置CMake打包参数 224 │ │ ├── hello.cpp // 实现Native侧的runTest接 225 │ ├── ets 226 │ │ ├── setpropertyability 227 │ │ ├── pages 228 │ │ ├── Index.ets // ArkTS侧调用C/C++方法实现 229 │ ├── module.json5 230 │ └── resources 231 ├── ohosTest 232 │ ├── ets 233 │ │ ├── test 234 │ │ ├── Ability.test.ets // 自动化测试代码 235``` 236 237### 相关权限 238 239不涉及。 240 241### 依赖 242 243不涉及。 244 245### 约束与限制 246 2471.本示例仅支持标准系统上运行, 支持设备:Phone。 248 2492.本示例为Stage模型,支持API15版本SDK,版本号:5.0.3.135,镜像版本号:HarmonyOS NEXT_5.0.3.135。 250 2513.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 252 253### 下载 254 255如需单独下载本工程,执行如下命令: 256 257``` 258git init 259git config core.sparsecheckout true 260echo code/DocsSample/ArkTS/JSVMAPI/JsvmUsageGuide/JsvmAboutProperty > .git/info/sparse-checkout 261git remote add origin https://gitee.com/openharmony/applications_app_samples.git 262git pull origin master 263``` 264