// ...
.onClick(() => {
let hashmap : HashMap<string,number> = new HashMap()
hashmap.set("Abc",123)
hashmap.set("Bcd",234)
hashmap.set("Cde",345)
for (let key of hashmap.keys()) {
testNapi.mapDemo(key, hashmap.get(key))
console.info(`key is ${key}, value is ${hashmap.get(key)}`)
}
})
// ...
当前没有专门的接口进行map在ArkTS侧与Native侧的转换,想要实现map(二维数组)数据交互,可以将map中的数据读取出来,传递到Native侧进行map重组。
参考代码如下:
ArkTS侧声明hashmap,并获取数据并传递到Native侧。
Native侧获取数据并重组map