/*! 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:'
Used to create, update, and delete receiving addresses.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { AddressEdit } from 'vant';\n\nconst app = createApp();\napp.use(AddressEdit);\n
\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
\nimport { 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
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
area-list | \nArea List | \nobject | \n- | \n
area-columns-placeholder | \nplaceholder of area columns | \nstring[] | \n[] | \n
area-placeholder | \nplaceholder of area input field | \nstring | \nArea | \n
address-info | \nAddress Info | \nAddressEditInfo | \n{} | \n
search-result | \nAddress search result | \nAddressEditSearchItem[] | \n[] | \n
show-delete | \nWhether to show delete button | \nboolean | \nfalse | \n
show-set-default | \nWhether to show default address switch | \nboolean | \nfalse | \n
show-search-result | \nWhether to show address search result | \nboolean | \nfalse | \n
show-area | \nWhether to show area cell | \nboolean | \ntrue | \n
show-detail | \nWhether to show detail field | \nboolean | \ntrue | \n
disable-area | \nWhether to disable area select | \nboolean | \nfalse | \n
save-button-text | \nSave button text | \nstring | \nSave | \n
delete-button-text | \nDelete button text | \nstring | \nDelete | \n
detail-rows | \nDetail input rows | \nnumber | string | \n1 | \n
detail-maxlength | \nDetail maxlength | \nnumber | string | \n200 | \n
is-saving | \nWhether to show save button loading status | \nboolean | \nfalse | \n
is-deleting | \nWhether to show delete button loading status | \nboolean | \nfalse | \n
tel-validator | \nThe method to validate tel | \n(val: string) => boolean | \n- | \n
tel-maxlength | \nTel maxlength | \nnumber | string | \n- | \n
validator | \nCustom validator | \n(key: string, val: string) => string | \n- | \n
Event | \nDescription | \nArguments | \n
---|---|---|
save | \nEmitted when the save button is clicked | \ninfo: AddressEditInfo | \n
focus | \nEmitted when field is focused | \nkey: string | \n
change v4.7.0 | \nEmitted when only the name and tel field are changed | \n{key: string, value: string} | \n
delete | \nEmitted when confirming delete | \ninfo: AddressEditInfo | \n
select-search | \nEmitted when a search result is selected | \nvalue: string | \n
click-area | \nEmitted when the area field is clicked | \n- | \n
change-area | \nEmitted when area changed | \nselectedOptions: PickerOption[] | \n
change-detail | \nEmitted when address detail changed | \nvalue: string | \n
change-default | \nEmitted when switching default address | \nchecked: boolean | \n
Name | \nDescription | \n
---|---|
default | \nCustom content below address detail | \n
Use ref to get AddressEdit instance and call instance methods.
\nName | \nDescription | \nAttribute | \nReturn value | \n
---|---|---|---|
setAddressDetail | \nSet address detail | \naddressDetail: string | \n- | \n
setAreaCode | \nSet area code | \ncode: string | \n- | \n
The component exports the following type definitions:
\nimport type {\n AddressEditInfo,\n AddressEditProps,\n AddressEditInstance,\n AddressEditSearchItem,\n} from 'vant';\n
\nAddressEditInstance
is the type of component instance:
import { ref } from 'vue';\nimport type { AddressEditInstance } from 'vant';\n\nconst addressEditRef = ref<AddressEditInstance>();\n\naddressEditRef.value?.setAddressDetail('');\n
\nkey | \nDescription | \nType | \n
---|---|---|
name | \nName | \nstring | \n
tel | \nPhone | \nstring | \n
province | \nProvince | \nstring | \n
city | \nCity | \nstring | \n
county | \nCounty | \nstring | \n
addressDetail | \nDetailed Address | \nstring | \n
areaCode | \nArea code | \nstring | \n
isDefault | \nIs default address | \nboolean | \n
key | \nDescription | \nType | \n
---|---|---|
name | \nName | \nstring | \n
address | \nAddress | \nstring | \n
Please refer to Area component.
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-address-edit-padding | \nvar(--van-padding-sm) | \n- | \n
--van-address-edit-buttons-padding | \nvar(--van-padding-xl) var(--van-padding-base) | \n- | \n
--van-address-edit-button-margin-bottom | \nvar(--van-padding-sm) | \n- | \n
--van-address-edit-button-font-size | \nvar(--van-font-size-lg) | \n- | \n