/*! For license information please see 7340.4db22a5b.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["7340"],{22839:function(n,s,t){"use strict";t.r(s);var a=t("80681");let e=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
Used to display the contact list.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { ContactList } from 'vant';\n\nconst app = createApp();\napp.use(ContactList);\n
\n<van-contact-list\n v-model="chosenContactId"\n :list="list"\n default-tag-text="default"\n @add="onAdd"\n @edit="onEdit"\n @select="onSelect"\n/>\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const chosenContactId = ref('1');\n const list = ref([\n {\n id: '1',\n name: 'John Snow',\n tel: '13000000000',\n isDefault: true,\n },\n {\n id: '2',\n name: 'Ned Stark',\n tel: '1310000000',\n },\n ]);\n\n const onAdd = () => showToast('Add');\n const onEdit = (contact) => showToast('Edit' + contact.id);\n const onSelect = (contact) => showToast('Select' + contact.id);\n\n return {\n list,\n onAdd,\n onEdit,\n onSelect,\n chosenContactId,\n };\n },\n};\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model | \nId of chosen contact | \nnumber | string | \n- | \n
list | \nContact list | \nContactListItem[] | \n[] | \n
add-text | \nAdd button text | \nstring | \nAdd new contact | \n
default-tag-text | \nDefault tag text | \nstring | \n- | \n
Event | \nDescription | \nArguments | \n
---|---|---|
add | \nEmitted when the add button is clicked | \n- | \n
edit | \nEmitted when the edit button is clicked | \ncontact: ContactListItem, index: number | \n
select | \nEmitted when a contact is selected | \ncontact: ContactListItem, index: number | \n
key | \nDescription | \nType | \n
---|---|---|
id | \nID | \nnumber | string | \n
name | \nName | \nstring | \n
tel | \nPhone | \nstring | \n
isDefault | \nIs default contact | \nboolean | undefined | \n
The component exports the following type definitions:
\nimport type { ContactListItem, ContactListProps } from 'vant';\n
\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-contact-list-padding | \nvar(--van-padding-sm) var(--van-padding-sm) 80px | \n- | \n
--van-contact-list-edit-icon-size | \n16px | \n- | \n
--van-contact-list-add-button-z-index | \n999 | \n- | \n
--van-contact-list-radio-color | \nvar(--van-primary-color) | \n- | \n
--van-contact-list-item-padding | \nvar(--van-padding-md) | \n- | \n