-
SubstituteOptions
指定替换选项的对象。
使用 format 属性定义字符串模板中引用的每个值的格式。
format
是一个键值对对象。每个键可以是:data
参数或substitute()
的属性- 可以在模板字符串中引用的命名格式化程序。
在以下示例中,
data
中的time
属性将被格式化为日期,每个组件都采用数字格式。const data = { time: Date.now() }; intl.substitute("Date: {time}", data, { format: { time: { type: "date", intlOptions: { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric" } } } });
以下示例使用命名格式化程序使用不同的格式化选项对
time
属性进行两次格式化。const data = { time: Date.now() }; intl.substitute("In {time:monthFormat} of {time:yearFormat}", data, { format: { monthFormat: { type: "date", intlOptions: { month: "long" } }, yearFormat: { type: "date", intlOptions: { year: "numeric" } } } });
- 属性:
-
类型 说明 format HashMap<(intl.SubstituteDateTimeFormatOptions|intl.SubstituteNumberFormatOptions)>格式化选项的字符串键的哈希映射。
基本信息
以下是所在类或对象的基本信息。
AMD:
require(["esri/intl"], (intl) => { /* code goes here */ });
ESM:
import * as intl from "@arcgis/core/intl";
对象:
esri/intl
自从:用于 JavaScript 4.12 的 ArcGIS API
用法说明
intl.SubstituteOptions
函数(或属性)的定义如下:
相关用法
- JavaScript ArcGIS intl.SubstituteDateTimeFormatOptions用法及代码示例
- JavaScript ArcGIS intl.SubstituteNumberFormatOptions用法及代码示例
- JavaScript ArcGIS intl.convertDateFormatToIntlOptions用法及代码示例
- JavaScript ArcGIS intl.normalizeMessageBundleLocale用法及代码示例
- JavaScript ArcGIS intl.fetchMessageBundle用法及代码示例
- JavaScript ArcGIS intl.formatNumber用法及代码示例
- JavaScript ArcGIS intl.convertNumberFormatToIntlOptions用法及代码示例
- JavaScript ArcGIS intl.createJSONLoader用法及代码示例
- JavaScript ArcGIS intl.registerMessageBundleLoader用法及代码示例
- JavaScript ArcGIS intl.setLocale用法及代码示例
- JavaScript ArcGIS intl.MessageBundleLoader用法及代码示例
- JavaScript ArcGIS intl.formatDate用法及代码示例
- JavaScript ArcGIS intl.onLocaleChange用法及代码示例
- JavaScript ArcGIS intl.substitute用法及代码示例
- JavaScript includes()用法及代码示例
- JavaScript isFinite()用法及代码示例
- JavaScript isNaN()用法及代码示例
- JavaScript ArcGIS imageService.getSamples用法及代码示例
- JavaScript ArcGIS SceneView double-click事件用法及代码示例
- JavaScript ArcGIS geometryEngineAsync.overlaps用法及代码示例
- JavaScript ArcGIS Expand.when用法及代码示例
- JavaScript ArcGIS Sublayer.JoinTableDataSource用法及代码示例
- JavaScript ArcGIS FillSymbol3DLayer.outline用法及代码示例
- JavaScript ArcGIS Ground.loadAll用法及代码示例
- JavaScript Object valueOf()用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 intl.SubstituteOptions。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。