Skip to content

ContactEdit - Vant 4

ContactEdit

Intro

Edit and save the contact information.

Install

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

js
import { createApp } from'vue'; import { ContactEdit } from'vant'; const app = createApp(); app.use(ContactEdit);

Usage

Basic Usage

html
js
import { ref } from'vue'; import { showToast } from'vant'; exportdefault { setup() { const editingContact = ref({ tel: '', name: '', }); constonSave = (contactInfo) => showToast('Save'); constonDelete = (contactInfo) => showToast('Delete'); return { onSave, onDelete, editingContact, }; }, };

API

Props

AttributeDescriptionTypeDefault
contact-infoContact InfoContactEditInfo{}
is-editWhether is editingbooleanfalse
is-savingWhether to show save button loading statusbooleanfalse
is-deletingWhether to show delete button loading statusbooleanfalse
tel-validatorThe method to validate tel(tel: string) => boolean-
show-set-defaultWhether to show default contact switchbooleanfalse
set-default-labeldefault contact switch labelstring-

Events

EventDescriptionArguments
saveEmitted when the save button is clickedcontent: contact info
deleteEmitted when the delete button is clickedcontent: contact info
change-defaultEmitted when the default contact is switchedchecked��contact is not the default

Data Structure of ContactEditInfo

keyDescriptionType
nameNamestring
telPhonestring
isDefaultIs Default*boolean

Types

The component exports the following type definitions:

ts
importtype { ContactEditInfo, ContactEditProps } from'vant';

Theming

CSS Variables

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

NameDefault ValueDescription
--van-contact-edit-paddingvar(--van-padding-md)-
--van-contact-edit-fields-radiusvar(--van-radius-md)-
--van-contact-edit-buttons-paddingvar(--van-padding-xl) 0-
--van-contact-edit-button-margin-bottomvar(--van-padding-sm)-
--van-contact-edit-button-font-sizevar(--van-font-size-lg)-
--van-contact-edit-field-label-width4.1em-

Enterprise-level mobile solution based on Vant