From d4457602da9bbd1ccd7558b4a4a40edb4ddfbb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E5=BA=86=E6=B3=89?= Date: Thu, 27 Jun 2024 19:21:51 +0800 Subject: [PATCH] Update array.md --- docs/uts/buildin-object-api/array.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/uts/buildin-object-api/array.md b/docs/uts/buildin-object-api/array.md index 8da0a5cc..bf3a1815 100644 --- a/docs/uts/buildin-object-api/array.md +++ b/docs/uts/buildin-object-api/array.md @@ -134,6 +134,24 @@ console.log(array1.fill(6)); ``` +需要注意的是,截止HBuilder 4.22 部分平台尚不支持[根据元素个数构造`Array`的写法](https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/array.html#constructor) + +所以下面的代码在 部分平台可能不符合预期 + + +```ts +new Array(20).fill(0) +``` + +可以使用下面的代码替代 + +```ts +let b = Array() +for(let i = 0; i < 20; i++){ + b.add(0) +} +``` + ### copyWithin(target, start?, end?) -- GitLab