/*! 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:'

ContactList

\n

Intro

\n

Used to display the contact list.

\n

Install

\n

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

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

Usage

\n

Basic Usage

\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
\n
import { 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
\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
AttributeDescriptionTypeDefault
v-modelId of chosen contactnumber | string-
listContact listContactListItem[][]
add-textAdd button textstringAdd new contact
default-tag-textDefault tag textstring-
\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
EventDescriptionArguments
addEmitted when the add button is clicked-
editEmitted when the edit button is clickedcontact: ContactListItem, index: number
selectEmitted when a contact is selectedcontact: ContactListItem, index: number
\n

Data Structure of ContactListItem

\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
idIDnumber | string
nameNamestring
telPhonestring
isDefaultIs default contactboolean | undefined
\n

Types

\n

The component exports the following type definitions:

\n
import type { ContactListItem, ContactListProps } from 'vant';\n
\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\n\n\n\n\n
NameDefault ValueDescription
--van-contact-list-paddingvar(--van-padding-sm) var(--van-padding-sm) 80px-
--van-contact-list-edit-icon-size16px-
--van-contact-list-add-button-z-index999-
--van-contact-list-radio-colorvar(--van-primary-color)-
--van-contact-list-item-paddingvar(--van-padding-md)-
\n
'},null,8,e))}}}]);