From f60e5fecce9ce4942b97a98d945c5f5946e9594b Mon Sep 17 00:00:00 2001 From: jwx1068251 Date: Wed, 11 Jan 2023 09:26:32 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0ScopeComparable=E5=86=85compareTo?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jwx1068251 --- .../reference/apis/js-apis-util.md | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index d9de989e44..82942c94a9 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -338,7 +338,7 @@ TextDecoder的构造函数。 ### create9+ -create(encoding?: string,options?: { fatal?: boolean; ignoreBOM?: boolean },): TextDecoder; +create(encoding?: string,options?: { fatal?: boolean; ignoreBOM?: boolean }): TextDecoder; 替代有参构造功能。 @@ -410,13 +410,13 @@ decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string ### constructor(deprecated) -constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean },) +constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean }) TextDecoder的构造函数。 > **说明:** > -> 从API version 7开始支持,从API version 9开始废弃,建议使用[constructor9+](#constructor9)替代。 +> 从API version 7开始支持,从API version 9开始废弃,建议使用[create9+](#create9)替代。 **系统能力:** SystemCapability.Utils.Lang @@ -440,7 +440,7 @@ TextDecoder的构造函数。 let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` -### decode +### decode(deprecated) decode(input: Uint8Array, options?: { stream?: false }): string @@ -448,7 +448,7 @@ decode(input: Uint8Array, options?: { stream?: false }): string > **说明:** > -> 从API version 7开始支持,从API version 9开始废弃,建议使用[decodeWithStream9+](#decodeWithStream9)替代。 +> 从API version 7开始支持,从API version 9开始废弃,建议使用[decodeWithStream9+](#decodewithstream9)替代。 **系统能力:** SystemCapability.Utils.Lang @@ -1590,28 +1590,32 @@ let result = pro[Symbol.iterator](); ScopeComparable类型的值需要实现compareTo方法,确保传入的数据具有可比性。 - ```js - interface ScopeComparable{ - compareTo(other: ScopeComparable): boolean; -} - ``` - **系统能力:** SystemCapability.Utils.Lang -## ScopeType8+ +### compareTo8+ -用于表示范围中的值的类型。 +compareTo(other: ScopeComparable): boolean; + +比较两个值的大小,返回一个布尔值。 **系统能力:** SystemCapability.Utils.Lang -| 类型 | 说明 | -| -------- | -------- | -| number | 表示值的类型为数字。 | -| [ScopeComparable](#ScopeComparable8) | 表示值的类型为ScopeComparable。| +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---- | ---- | -------------- | +| other | [ScopeComparable](#scopecomparable8) | 是 | 表示要比较的值。 | + +**返回值:** + +| 类型 | 说明 | +| ---- | ------------------ | +| boolean | 调用compareTo的值大于等于传入的值返回true,否则返回false。| -构造新类,实现compareTo方法。后续示例代码中,均通过Temperature,获取[ScopeType](#scopetype8)的实例化对象。 +**示例:** + +构造新类,实现compareTo方法。后续示例代码中,均以此Temperature类为例。 -示例: ```js class Temperature{ constructor(value){ @@ -1631,6 +1635,17 @@ class Temperature{ } ``` +## ScopeType8+ + +用于表示范围中的值的类型。 + +**系统能力:** SystemCapability.Utils.Lang + +| 类型 | 说明 | +| -------- | -------- | +| number | 表示值的类型为数字。 | +| [ScopeComparable](#scopecomparable8) | 表示值的类型为ScopeComparable。| + ## ScopeHelper9+ ### constructor9+ @@ -1710,7 +1725,7 @@ let range = new util.ScopeHelper(tempLower, tempUpper); let tempMiDF = new Temperature(35); let tempMidS = new Temperature(39); let rangeFir = new util.ScopeHelper(tempMiDF, tempMidS); -range.intersect(rangeFir ); +range.intersect(rangeFir); ``` -- GitLab