ContactAddress
ContactAddress 介面是 聯絡人選擇器 API 的一部分,代表一個物理地址。此介面的例項是從 ContactsManager.getProperties() 返回的物件中的 address 屬性中檢索到的。
引用萬國郵政聯盟網站的 S42 地址標準 材料可能很有用,這些材料提供了有關郵政地址國際標準的資訊。
例項屬性
ContactAddress.addressLine只讀 實驗性-
一個字串陣列,提供地址中未包含在其他屬性中的每一行。具體大小和內容因國家或地區而異,可能包含,例如,街道名稱、門牌號、公寓號、鄉村投遞路線、描述性說明或郵政信箱號碼。
ContactAddress.country只讀 實驗性-
一個字串,指定地址所在的國家/地區,使用 ISO-3166-1 alpha-2 標準。字串始終以其規範的大寫形式給出。有效的
country值的一些示例:"US"、"GB"、"CN"或"JP"。 ContactAddress.city只讀 實驗性-
一個字串,包含地址的城市或城鎮部分。
ContactAddress.dependentLocality只讀 實驗性-
一個字串,表示城市內的從屬區域或次級區域,例如,一個街區、區、地區或英國的從屬區域。
ContactAddress.organization只讀 實驗性-
一個字串,指定地址所在的組織、公司、企業或機構的名稱。
ContactAddress.phone只讀 實驗性-
一個字串,指定收件人或聯絡人的電話號碼。
ContactAddress.postalCode只讀 實驗性-
一個字串,指定管轄區用於郵件路由的程式碼,例如,美國的 ZIP 程式碼或印度的 PIN 程式碼。
ContactAddress.recipient只讀 實驗性-
一個字串,表示地址中的收件人、購買者或聯絡人的姓名。
ContactAddress.region只讀 實驗性-
一個字串,包含國家/地區的高階行政區劃,例如州、省、州(俄羅斯)或縣(日本)。
ContactAddress.sortingCode只讀 實驗性-
一個字串,提供郵政分揀程式碼,例如在法國使用的程式碼。
例項方法
ContactAddress.toJSON()實驗性-
一個標準的序列化器,返回
ContactAddress物件屬性的 JSON 表示。
示例
以下示例提示使用者選擇聯絡人,然後將返回的第一個地址列印到控制檯。
js
const props = ["address"];
const opts = { multiple: true };
async function getContacts() {
try {
const contacts = await navigator.contacts.select(props, opts);
const contactAddress = contacts[0].address[0];
console.log(contactAddress);
} catch (ex) {
// Handle any errors here.
}
}
規範
| 規範 |
|---|
| 聯絡人選擇器 API # contactaddress |
瀏覽器相容性
載入中…