/*! For license information please see 9727.3f9fa01b.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["9727"],{39368:function(t,n,s){"use strict";s.r(n);var e=s("80681");let d=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,e.wg)(),(0,e.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

AddressEdit

\n

Intro

\n

Used to create, update, and delete receiving addresses.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

\n
import { createApp } from 'vue';\nimport { AddressEdit } from 'vant';\n\nconst app = createApp();\napp.use(AddressEdit);\n
\n

Usage

\n

Basic Usage

\n
<van-address-edit\n  :area-list="areaList"\n  show-delete\n  show-set-default\n  show-search-result\n  :search-result="searchResult"\n  :area-columns-placeholder="['Choose', 'Choose', 'Choose']"\n  @save="onSave"\n  @delete="onDelete"\n  @change-detail="onChangeDetail"\n/>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const searchResult = ref([]);\n\n    const onSave = () => showToast('save');\n    const onDelete = () => showToast('delete');\n    const onChangeDetail = (val) => {\n      if (val) {\n        searchResult.value = [\n          {\n            name: 'Name1',\n            address: 'Address',\n          },\n        ];\n      } else {\n        searchResult.value = [];\n      }\n    };\n\n    return {\n      onSave,\n      onDelete,\n      areaList,\n      searchResult,\n      onChangeDetail,\n    };\n  },\n};\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
area-listArea Listobject-
area-columns-placeholderplaceholder of area columnsstring[][]
area-placeholderplaceholder of area input fieldstringArea
address-infoAddress InfoAddressEditInfo{}
search-resultAddress search resultAddressEditSearchItem[][]
show-deleteWhether to show delete buttonbooleanfalse
show-set-defaultWhether to show default address switchbooleanfalse
show-search-resultWhether to show address search resultbooleanfalse
show-areaWhether to show area cellbooleantrue
show-detailWhether to show detail fieldbooleantrue
disable-areaWhether to disable area selectbooleanfalse
save-button-textSave button textstringSave
delete-button-textDelete button textstringDelete
detail-rowsDetail input rowsnumber | string1
detail-maxlengthDetail maxlengthnumber | string200
is-savingWhether to show save button loading statusbooleanfalse
is-deletingWhether to show delete button loading statusbooleanfalse
tel-validatorThe method to validate tel(val: string) => boolean-
tel-maxlengthTel maxlengthnumber | string-
validatorCustom validator(key: string, val: string) => string-
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
saveEmitted when the save button is clickedinfo: AddressEditInfo
focusEmitted when field is focusedkey: string
change v4.7.0Emitted when only the name and tel field are changed{key: string, value: string}
deleteEmitted when confirming deleteinfo: AddressEditInfo
select-searchEmitted when a search result is selectedvalue: string
click-areaEmitted when the area field is clicked-
change-areaEmitted when area changedselectedOptions: PickerOption[]
change-detailEmitted when address detail changedvalue: string
change-defaultEmitted when switching default addresschecked: boolean
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
defaultCustom content below address detail
\n

Methods

\n

Use ref to get AddressEdit instance and call instance methods.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescriptionAttributeReturn value
setAddressDetailSet address detailaddressDetail: string-
setAreaCodeSet area codecode: string-
\n

Types

\n

The component exports the following type definitions:

\n
import type {\n  AddressEditInfo,\n  AddressEditProps,\n  AddressEditInstance,\n  AddressEditSearchItem,\n} from 'vant';\n
\n

AddressEditInstance is the type of component instance:

\n
import { ref } from 'vue';\nimport type { AddressEditInstance } from 'vant';\n\nconst addressEditRef = ref<AddressEditInstance>();\n\naddressEditRef.value?.setAddressDetail('');\n
\n

AddressEditInfo Data Structure

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
keyDescriptionType
nameNamestring
telPhonestring
provinceProvincestring
cityCitystring
countyCountystring
addressDetailDetailed Addressstring
areaCodeArea codestring
isDefaultIs default addressboolean
\n

AddressEditSearchItem Data Structure

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
keyDescriptionType
nameNamestring
addressAddressstring
\n

Area Data Structure

\n

Please refer to Area component.

\n

Theming

\n

CSS Variables

\n

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDefault ValueDescription
--van-address-edit-paddingvar(--van-padding-sm)-
--van-address-edit-buttons-paddingvar(--van-padding-xl) var(--van-padding-base)-
--van-address-edit-button-margin-bottomvar(--van-padding-sm)-
--van-address-edit-button-font-sizevar(--van-font-size-lg)-
\n
'},null,8,d))}}}]);