Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b893337d
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b893337d
编写于
6月 22, 2022
作者:
K
king_he
提交者:
Gitee
6月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/internationalization/intl-guidelines.md.
Signed-off-by:
N
king_he
<
6384784@qq.com
>
上级
d2211451
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
104 addition
and
85 deletion
+104
-85
zh-cn/application-dev/internationalization/intl-guidelines.md
...n/application-dev/internationalization/intl-guidelines.md
+104
-85
未找到文件。
zh-cn/application-dev/internationalization/intl-guidelines.md
浏览文件 @
b893337d
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方法。
Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方法。
## 设置区域信息
## 设置区域信息
调用
[
Locale
](
../reference/apis/js-apis-intl.md
)
的相关接口实现最大化区域信息或最小化区域信息。
调用
[
Locale
](
../reference/apis/js-apis-intl.md
)
的相关接口实现最大化区域信息或最小化区域信息。
...
@@ -11,17 +10,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -11,17 +10,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | ------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 实例化Locale对象。 |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 实例化Locale对象。 |
| ohos.intl | constructor(locale:
string,
options?:
LocaleOptions) | 基于locale参数及其选项实例化Locale对象。 |
| ohos.intl | constructor(locale:
string,options?:
LocaleOptions) | 基于locale参数及其选项实例化Locale对象。 |
| ohos.intl | toString():
string | 将Locale信息转换为字符串。
|
| ohos.intl | toString():
string | 将Locale信息转换为字符串。
|
| ohos.intl | maximize():
Locale | 最大化区域信息。
|
| ohos.intl | maximize():
Locale | 最大化区域信息。
|
| ohos.intl | minimize():
Locale | 最小化区域信息。
|
| ohos.intl | minimize():
Locale | 最小化区域信息。
|
### 开发步骤
### 开发步骤
1.
实例化Locale对象
1.
实例化Locale对象。
使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的
[
属性
](
../reference/apis/js-apis-intl.md
)
列表(intl为导入的模块名)。
使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的
[
属性
](
../reference/apis/js-apis-intl.md
)
列表(intl为导入的模块名)。
...
@@ -31,21 +31,24 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -31,21 +31,24 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var localeObj = new intl.Locale(locale, options);
var localeObj = new intl.Locale(locale, options);
```
```
2.
获取Locale的字符串表示
2.
获取Locale的字符串表示。
调用toString方法来获取Locale对象的字符串表示,其中包括了语言、区域及其他选项信息。
调用toString方法来获取Locale对象的字符串表示,其中包括了语言、区域及其他选项信息。
```
```
var localeStr = localeObj.toString();
var localeStr = localeObj.toString();
```
```
3.
最大化区域信息
3.
最大化区域信息。
调用maximize方法来最大化区域信息,即当缺少脚本与地区信息时,对其进行补全。
调用maximize方法来最大化区域信息,即当缺少脚本与地区信息时,对其进行补全。
```
```
var maximizedLocale = localeObj.maximize();
var maximizedLocale = localeObj.maximize();
```
```
4.
最小化区域信息
4.
最小化区域信息。
调用minimize方法来最小化区域信息,即当存在脚本与地区信息时,对其进行删除。
调用minimize方法来最小化区域信息,即当存在脚本与地区信息时,对其进行删除。
```
```
...
@@ -61,17 +64,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -61,17 +64,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | --------------------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建日期时间格式化对象。 |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建日期时间格式化对象。 |
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,
options?:
DateTimeOptions) | 创建日期时间格式化对象,并设置提供的Locale和格式化相关属性。
|
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,options?:DateTimeOptions) | 创建日期时间格式化对象,并设置提供的Locale和格式化相关属性。
|
| ohos.intl | format(date:
Date):
string
| 依据DateTimeFormat对象的Locale及其他格式化属性,计算日期时间的格式化表示。 |
| ohos.intl | format(date:
Date):string
| 依据DateTimeFormat对象的Locale及其他格式化属性,计算日期时间的格式化表示。 |
| ohos.intl | formatRange(startDate:
Date,
endDate:
Date):
string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算时间段的格式化表示。 |
| ohos.intl | formatRange(startDate:
Date,endDate:Date):
string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算时间段的格式化表示。 |
| ohos.intl | resolvedOptions():
DateTimeOptions | 获取DateTimeFormat对象的相关属性。
|
| ohos.intl | resolvedOptions():
DateTimeOptions | 获取DateTimeFormat对象的相关属性。
|
### 开发步骤
### 开发步骤
1.
实例化日期时间格式化对象
1.
实例化日期时间格式化对象。
一种方法是使用DateTimeFormat提供的默认构造函数,通过访问系统语言和地区设置,获取系统默认Locale,并将其作为DateTimeFormat对象内部的Locale(intl为导入的模块名)。
一种方法是使用DateTimeFormat提供的默认构造函数,通过访问系统语言和地区设置,获取系统默认Locale,并将其作为DateTimeFormat对象内部的Locale(intl为导入的模块名)。
...
@@ -86,7 +90,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -86,7 +90,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options);
var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options);
```
```
2.
格式化日期时间
2.
格式化日期时间。
使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。
使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。
```
```
...
@@ -94,7 +99,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -94,7 +99,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var formatResult = dateTimeFormat.format(date);
var formatResult = dateTimeFormat.format(date);
```
```
3.
格式化时间段
3.
格式化时间段。
使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止时间,返回一个字符串作为格式化的结果。
使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止时间,返回一个字符串作为格式化的结果。
```
```
...
@@ -103,7 +109,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -103,7 +109,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var formatResult = dateTimeFormat.formatRange(startDate, endDate);
var formatResult = dateTimeFormat.formatRange(startDate, endDate);
```
```
4.
访问日期时间格式化对象的相关属性
4.
访问日期时间格式化对象的相关属性。
DateTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了DateTimeFormat对象的所有相关属性及其值。
DateTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了DateTimeFormat对象的所有相关属性及其值。
```
```
...
@@ -119,16 +126,17 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -119,16 +126,17 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | --------------------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<SUP>
8+
</SUP>
| 创建数字格式化对象。 |
| ohos.intl | constructor()
<SUP>
8+
</SUP>
| 创建数字格式化对象。 |
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,
options?:
NumberOptions) | 创建数字格式化对象,并设置提供的locale和格式化相关属性。
|
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,options?:NumberOptions) | 创建数字格式化对象,并设置提供的locale和格式化相关属性。
|
| ohos.intl | format(number:
number):
string | 依据NumberFormat对象的Locale及其他格式化属性,计算数字的格式化表示。 |
| ohos.intl | format(number:
number):
string | 依据NumberFormat对象的Locale及其他格式化属性,计算数字的格式化表示。 |
| ohos.intl | resolvedOptions():
NumberOptions | 获取NumberFormat对象的相关属性。
|
| ohos.intl | resolvedOptions():
NumberOptions | 获取NumberFormat对象的相关属性。
|
### 开发步骤
### 开发步骤
1.
实例化数字格式化对象
1.
实例化数字格式化对象。
一种方法是使用NumberFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
一种方法是使用NumberFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
...
@@ -143,7 +151,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -143,7 +151,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var numberFormat = new intl.NumberFormat("zh-CN", options);
var numberFormat = new intl.NumberFormat("zh-CN", options);
```
```
2.
数字格式化
2.
数字格式化。
使用NumberFormat的format方法对传入的数字进行格式化。该方法返回一个字符串作为格式化的结果。
使用NumberFormat的format方法对传入的数字进行格式化。该方法返回一个字符串作为格式化的结果。
```
```
...
@@ -151,7 +160,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -151,7 +160,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var formatResult = numberFormat.format(number);
var formatResult = numberFormat.format(number);
```
```
3.
访问数字格式化对象的相关属性
3.
访问数字格式化对象的相关属性。
NumberFormat的resolvedOptions方法会返回一个对象,该对象包含了NumberFormat对象的所有相关属性及其值。
NumberFormat的resolvedOptions方法会返回一个对象,该对象包含了NumberFormat对象的所有相关属性及其值。
```
```
...
@@ -167,16 +177,17 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -167,16 +177,17 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | -----------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建排序对象。 |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建排序对象。 |
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,
options?:
CollatorOptions)
<sup>
8+
</sup>
| 创建排序对象,并设置提供的locale和其他相关属性。
|
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,options?:CollatorOptions)
<sup>
8+
</sup>
| 创建排序对象,并设置提供的locale和其他相关属性。
|
| ohos.intl | compare(first:
string,
second:
string):
number
<sup>
8+
</sup>
| 依据排序对象的Locale及其属性,计算两个字符串的比较结果。 |
| ohos.intl | compare(first:
string,second:string):
number
<sup>
8+
</sup>
| 依据排序对象的Locale及其属性,计算两个字符串的比较结果。 |
| ohos.intl | resolvedOptions():
CollatorOptions
<sup>
8+
</sup>
| 获取排序对象的相关属性。
|
| ohos.intl | resolvedOptions():
CollatorOptions
<sup>
8+
</sup>
| 获取排序对象的相关属性。
|
### 开发步骤
### 开发步骤
1.
实例化排序对象
1.
实例化排序对象。
一种方法是使用Collator提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
一种方法是使用Collator提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
...
@@ -190,7 +201,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -190,7 +201,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"};
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"};
```
```
2.
比较字符串
2.
比较字符串。
使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。
使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。
```
```
...
@@ -199,7 +211,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -199,7 +211,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var compareResult = collator.compare(str1, str2);
var compareResult = collator.compare(str1, str2);
```
```
3.
访问排序对象的相关属性
3.
访问排序对象的相关属性。
Collator的resolvedOptions方法会返回一个对象,该对象包含了Collator对象的所有相关属性及其值。
Collator的resolvedOptions方法会返回一个对象,该对象包含了Collator对象的所有相关属性及其值。
```
```
...
@@ -215,15 +228,16 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -215,15 +228,16 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | --------------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建单复数对象。 |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建单复数对象。 |
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,
options?:
PluralRulesOptions)
<sup>
8+
</sup>
| 创建单复数对象,并设置提供的locale和其他相关属性。
|
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,options?:PluralRulesOptions)
<sup>
8+
</sup>
| 创建单复数对象,并设置提供的locale和其他相关属性。
|
| ohos.intl | select(n:
number):
string
<sup>
8+
</sup>
| 依据单复数对象的Locale及其他格式化属性,计算数字的单复数类别。 |
| ohos.intl | select(n:
number):
string
<sup>
8+
</sup>
| 依据单复数对象的Locale及其他格式化属性,计算数字的单复数类别。 |
### 开发步骤
### 开发步骤
1.
实例化单复数对象
1.
实例化单复数对象。
一种方法是使用PluralRules提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
一种方法是使用PluralRules提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
...
@@ -231,13 +245,14 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -231,13 +245,14 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var pluralRules = new intl.PluralRules();
var pluralRules = new intl.PluralRules();
```
```
另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象
,
完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md)。
另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象
。
完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md)。
```
```
var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"};
var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"};
```
```
2.
计算数字单复数类别
2.
计算数字单复数类别。
使用PluralRules的select方法计算传入数字的单复数类别。该方法返回一个字符串作为传入数字的类别,包括:"zero", "one", "two", "few", "many", "other"六个类别。
使用PluralRules的select方法计算传入数字的单复数类别。该方法返回一个字符串作为传入数字的类别,包括:"zero", "one", "two", "few", "many", "other"六个类别。
```
```
...
@@ -254,17 +269,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -254,17 +269,18 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
### 接口说明
| 模块 | 接口名称 | 描述 |
| 模块 | 接口名称 | 描述 |
| --------
- | ---------------------------------------- | --------------------------------
-------- |
| --------
| -------- |
-------- |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建相对时间格式化对象。 |
| ohos.intl | constructor()
<sup>
8+
</sup>
| 创建相对时间格式化对象。 |
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,
options?:
RelativeTimeFormatInputOptions)
<sup>
8+
</sup>
| 创建相对时间格式化对象,并设置提供的locale和格式化相关属性。
|
| ohos.intl | constructor(locale:
string
\|
Array
<
string
>
,options?:RelativeTimeFormatInputOptions)
<sup>
8+
</sup>
| 创建相对时间格式化对象,并设置提供的locale和格式化相关属性。
|
| ohos.intl | format(value:
number,
unit:
string):
string
<sup>
8+
</sup>
| 依据相对时间格式化对象的Locale及其他格式化属性,计算相对时间的格式化表示。 |
| ohos.intl | format(value:
number,unit:string):
string
<sup>
8+
</sup>
| 依据相对时间格式化对象的Locale及其他格式化属性,计算相对时间的格式化表示。 |
| ohos.intl | formatToParts(value:
number,
unit:
string):
Array
<
object
>
<sup>
8+
</sup>
| 依据相对时间格式化对象的Locale及其他格式化属性,返回相对时间格式化表示的各个部分。 |
| ohos.intl | formatToParts(value:
number,unit:string):
Array
<
object
>
<sup>
8+
</sup>
| 依据相对时间格式化对象的Locale及其他格式化属性,返回相对时间格式化表示的各个部分。 |
| ohos.intl | resolvedOptions():
RelativeTimeFormatResolvedOptions
<sup>
8+
</sup>
| 获取相对时间格式化对象的相关属性。
|
| ohos.intl | resolvedOptions():
RelativeTimeFormatResolvedOptions
<sup>
8+
</sup>
| 获取相对时间格式化对象的相关属性。
|
### 开发步骤
### 开发步骤
1.
实例化相对时间格式化对象
1.
实例化相对时间格式化对象。
一种方法是使用RelativeTimeFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
一种方法是使用RelativeTimeFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
...
@@ -278,7 +294,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -278,7 +294,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"};
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"};
```
```
2.
相对时间格式化
2.
相对时间格式化。
使用RelativeTimeFormat的format方法对相对时间进行格式化。方法接收一个表示相对时间长度的数值和表示单位的字符串,其中单位包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。方法返回一个字符串作为格式化的结果。
使用RelativeTimeFormat的format方法对相对时间进行格式化。方法接收一个表示相对时间长度的数值和表示单位的字符串,其中单位包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。方法返回一个字符串作为格式化的结果。
```
```
...
@@ -287,7 +304,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -287,7 +304,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var formatResult = relativeTimeFormat.format(number, unit);
var formatResult = relativeTimeFormat.format(number, unit);
```
```
3.
获取相对时间格式化结果的各个部分
3.
获取相对时间格式化结果的各个部分。
获取相对时间格式化结果的各个部分,从而自定义格式化结果。
获取相对时间格式化结果的各个部分,从而自定义格式化结果。
```
```
...
@@ -296,7 +314,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
...
@@ -296,7 +314,8 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
var formatResult = relativeTimeFormat.formatToParts(number, unit);
var formatResult = relativeTimeFormat.formatToParts(number, unit);
```
```
4.
访问相对时间格式化对象的相关属性
4.
访问相对时间格式化对象的相关属性。
RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md)。
RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md)。
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录