-
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。