From 6bcb40f13927111a6a1cbae5378b718f00abb131 Mon Sep 17 00:00:00 2001 From: coollixin Date: Thu, 31 Aug 2023 18:09:56 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20a89d83c=20from=20https://gitee.com/cool?= =?UTF-8?q?lixin/docs/pulls/23626=20arkts=E6=95=B4=E6=94=B9docs=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20Issue:=20https://gitee.com/openharmony/docs/issues/?= =?UTF-8?q?I7XKSW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: coollixin --- .../reference/apis/js-apis-arraylist.md | 2 +- .../reference/apis/js-apis-buffer.md | 10 ++++----- .../reference/apis/js-apis-deque.md | 14 ++++++------ .../reference/apis/js-apis-hashmap.md | 16 +++++++------- .../reference/apis/js-apis-hashset.md | 6 ++--- .../reference/apis/js-apis-lightweightmap.md | 10 ++++----- .../reference/apis/js-apis-lightweightset.md | 4 ++-- .../reference/apis/js-apis-linkedlist.md | 4 ++-- .../reference/apis/js-apis-list.md | 4 ++-- .../reference/apis/js-apis-plainarray.md | 4 ++-- .../reference/apis/js-apis-queue.md | 4 ++-- .../reference/apis/js-apis-stack.md | 4 ++-- .../reference/apis/js-apis-treemap.md | 22 +++++++++---------- .../reference/apis/js-apis-treeset.md | 12 +++++----- .../reference/apis/js-apis-vector.md | 8 +++---- 15 files changed, 62 insertions(+), 62 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 47fe1ca88c..fa14e6490a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -456,7 +456,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.forEach((value: number, index: number) => { +arrayList.forEach((value: number, index?: number) => { console.log("hyq value:" + value, "index:" + index); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-buffer.md b/zh-cn/application-dev/reference/apis/js-apis-buffer.md index 21f9ec0328..86b5ae373b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-buffer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-buffer.md @@ -634,9 +634,9 @@ import buffer from '@ohos.buffer'; let buf = buffer.from('buffer'); let pair = buf.entries() -let next = pair.next() +let next: IteratorResult = pair.next() while (!next.done) { - console.info(next.value) + console.info("buffer: " + next.value) next = pair.next() } ``` @@ -1963,7 +1963,7 @@ import buffer from '@ohos.buffer'; let buf1 = buffer.from('buffer'); let pair = buf1.values() -let next = pair.next() +let next:IteratorResult = pair.next() while (!next.done) { console.log(next.value.toString()); next = pair.next() @@ -2923,8 +2923,8 @@ import buffer from '@ohos.buffer'; let blob: buffer.Blob = new buffer.Blob(['a', 'b', 'c']); class option { - endings: string - type: string + endings: string = "" + type: string = "" } let o1: option = {endings:'native', type: 'MIME'} let blob1: buffer.Blob = new buffer.Blob(['a', 'b', 'c'], o1); diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 78cd11dee5..1d7a42346d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -119,8 +119,8 @@ insertEnd(element: T): void ```ts class C1 { - name: string - age: string + name: string = "" + age: string = "" } let deque: Deque | C1> = new Deque(); @@ -277,7 +277,7 @@ deque.insertFront(2); deque.insertEnd(4); deque.insertFront(5); deque.insertEnd(4); -deque.forEach((value: number, index: number) => { +deque.forEach((value: number, index?: number | undefined, deque?: Deque | undefined):void => { console.log("value:" + value, "index:" + index); }); ``` @@ -386,9 +386,9 @@ for (let item of nums) { // 使用方法二: let iter = deque[Symbol.iterator](); -let temp = iter.next().value; -while(temp != undefined) { - console.log("value:" + temp); - temp = iter.next().value; +let temp:IteratorResult = iter.next(); +while(!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index 3b7d17589f..7fdf5741a7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -363,7 +363,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.keys(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -400,7 +400,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.values(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -482,7 +482,7 @@ callbackfn的参数说明: let hashMap: HashMap = new HashMap(); hashMap.set("sparrow", 123); hashMap.set("gull", 357); -hashMap.forEach((value: number, key: string) => { +hashMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -517,7 +517,7 @@ let hashMap: HashMap = new HashMap(); hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); let iter = hashMap.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -555,14 +555,14 @@ hashMap.set("squirrel", 123); hashMap.set("sparrow", 356); // 使用方法一: -for (let item of hashMap) { - console.log("key:" + item[0]); - console.log("value:" + item[1]); +for (let key of keys) { + console.log("key:" + key); + console.log("value:" + hashMap.get(key)); } // 使用方法二: let iter = hashMap[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("key:" + temp[0]); console.log("value:" + temp[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index c005c709c1..3602774710 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -305,7 +305,7 @@ callbackfn的参数说明: let hashSet: HashSet = new HashSet(); hashSet.add("sparrow"); hashSet.add("squirrel"); -hashSet.forEach((value: string, key: string) => { +hashSet.forEach((value?: string, key?: string): void => { console.log("value:" + value, "key:" + key); }); ``` @@ -339,7 +339,7 @@ let hashSet: HashSet = new HashSet(); hashSet.add("squirrel"); hashSet.add("sparrow"); let iter = hashSet.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -385,7 +385,7 @@ for (let item of val) { // 使用方法二: let iter = hashSet[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value: " + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md index 8fba1f137b..846ad3a55c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @@ -666,7 +666,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.keys(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -703,7 +703,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.values(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); @@ -747,7 +747,7 @@ callbackfn的参数说明: let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("sparrow", 123); lightWeightMap.set("gull", 357); -lightWeightMap.forEach((value: number, key: string) => { +lightWeightMap.forEach((value?: number, key?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -782,7 +782,7 @@ let lightWeightMap: LightWeightMap = new LightWeightMap(); lightWeightMap.set("squirrel", 123); lightWeightMap.set("sparrow", 356); let iter = lightWeightMap.entries(); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); @@ -863,7 +863,7 @@ for (let item2 of key) { // 使用方法二: let iter = lightWeightMap[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index a17e0d730b..4b9f2e180b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -611,7 +611,7 @@ callbackfn的参数说明: let lightWeightSet: LightWeightSet = new LightWeightSet(); lightWeightSet.add("sparrow"); lightWeightSet.add("gull"); -lightWeightSet.forEach((value:string, key:string) => { +lightWeightSet.forEach((value ?: string, key ?: string) => { console.log("value:" + value, "key:" + key); }); ``` @@ -691,7 +691,7 @@ for (let item of nums) { // 使用方法二: let iter = lightWeightSet[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 366052f94e..865946c1fd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -641,7 +641,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.forEach((value:number, index: number) => { +linkedList.forEach((value: number, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -851,7 +851,7 @@ for (let item of items) { // 使用方法二: let iter = linkedList[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value:" + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index f151ac9e52..69c2d4312e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -503,7 +503,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.forEach((value:number, index:number) => { +list.forEach((value: number, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -829,7 +829,7 @@ for (let item of items) { // 使用方法二: let iter = list[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("value: " + temp.value); temp = iter.next(); diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 654ca7fffe..cee70aef8d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -620,7 +620,7 @@ callbackfn的参数说明: let plainArray: PlainArray = new PlainArray(); plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); -plainArray.forEach((value:string, index: number) => { +plainArray.forEach((value: string, index?: number) => { console.log("value:" + value, "index:" + index); }); ``` @@ -656,7 +656,7 @@ plainArray.add(1, "squirrel"); plainArray.add(2, "sparrow"); let iter = plainArray[Symbol.iterator](); -let temp = iter.next(); +let temp: IteratorResult = iter.next(); while(!temp.done) { console.log("key:" + temp.value[0]); console.log("value:" + temp.value[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index 4d5d035a77..a4626d6597 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -206,7 +206,7 @@ queue.add(2); queue.add(4); queue.add(5); queue.add(4); -queue.forEach((value : number, index : number) : void => { +queue.forEach((value : number, index ?: number) : void => { console.log("value:" + value, "index:" + index); }); ``` @@ -249,7 +249,7 @@ while(queue.length) { // 使用方法二: let iter = queue[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index f8f3db16bc..69845d5a89 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -244,7 +244,7 @@ stack.push(2); stack.push(4); stack.push(5); stack.push(4); -stack.forEach((value : number, index : number) :void => { +stack.forEach((value : number, index ?: number) :void => { console.log("value:" + value, "index:" + index); }); ``` @@ -321,7 +321,7 @@ while(!stack.isEmpty()) { // 使用方法二: let iter = stack[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index b8ebb8f469..22b7aff92b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -302,7 +302,7 @@ treeMap.set("sparrow", 356); let map : TreeMap = new TreeMap(); map.set("demo", 12); map.setAll(treeMap); // 将treeMap中的所有元素添加到map中 -map.forEach((value : number, key : string) : void => { +map.forEach((value ?: number, key ?: string) : void => { console.log("value" + value, "key" + key); // 打印结果 12 demo、356 sparrow、123 squirrel }) ``` @@ -553,9 +553,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -590,9 +590,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -634,7 +634,7 @@ callbackFn的参数说明: let treeMap : TreeMap = new TreeMap(); treeMap.set("sparrow", 123); treeMap.set("gull", 357); -treeMap.forEach((value : number, key : string) : void => { +treeMap.forEach((value ?: number, key ?: string) : void => { console.log("value:" + value, "key:" + key); }); ``` @@ -669,9 +669,9 @@ let treeMap : TreeMap = new TreeMap(); treeMap.set("squirrel", 123); treeMap.set("sparrow", 356); let it = treeMap.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() } ``` @@ -707,14 +707,14 @@ treeMap.set("sparrow", 356); // 使用方法一: let it = treeMap.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeMap" + t.value); t = it.next() // 使用方法二: let iter = treeMap[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("key:" + temp[0]); console.log("value:" + temp[1]); diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index 15d2f21484..7737c82bd3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -462,9 +462,9 @@ let treeSet : TreeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let it = treeSet.values(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeSet: " + t.value); t = it.next() } ``` @@ -506,7 +506,7 @@ callbackFn的参数说明: let treeSet : TreeSet = new TreeSet(); treeSet.add("sparrow"); treeSet.add("gull"); -treeSet.forEach((value : string, key : string) :void => { +treeSet.forEach((value ?: string, key ?: string) :void => { console.log("value:" + value, "key:" + key); }); ``` @@ -541,9 +541,9 @@ let treeSet : TreeSet = new TreeSet(); treeSet.add("squirrel"); treeSet.add("sparrow"); let it = treeSet.entries(); -let t = it.next(); +let t: IteratorResult = it.next(); while(!t.done) { - console.log(t.value); + console.log("TreeSet: " + t.value); t = it.next() } ``` @@ -585,7 +585,7 @@ for (let item of numbers) { } // 使用方法二: let iter = treeSet[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index a01b694cf6..f5ab7b7de0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -44,7 +44,7 @@ Vector的构造函数。 **示例:** ```ts -let vector : Vector> = new Vector(); +let vector : Vector> = new Vector(); ``` @@ -359,12 +359,12 @@ callbackfn的参数说明: **示例:** ```ts -let vector : Vector> = new Vector(); +let vector : Vector = new Vector(); vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.forEach((value : Vector> , index : number) : void => { +vector.forEach((value : number, index ?: number) : void => { console.log("value:" + value, "index:" + index); }); ``` @@ -864,7 +864,7 @@ for (let item of nums) { // 使用方法二: let iter = vector[Symbol.iterator](); -let temp = iter.next().value; +let temp: IteratorResult = iter.next().value; while(temp != undefined) { console.log("value:" + temp); temp = iter.next().value; -- GitLab