vant/src/contact-card
neverland c3ad21791b
docs: prefer using ref (#9285)
* docs: prefer using ref

* docs: fix lint error
2021-08-18 16:39:09 +08:00
..
2021-03-09 15:39:26 +08:00
2021-03-08 17:14:55 +08:00
2021-08-18 16:39:09 +08:00
2021-08-18 16:39:09 +08:00

ContactCard

Intro

Display contact information in the form of cards.

Install

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

import { createApp } from 'vue';
import { ContactCard } from 'vant';

const app = createApp();
app.use(ContactCard);

Usage

Add Contact

<van-contact-card type="add" @click="onAdd" />
import { Toast } from 'vant';

export default {
  setup() {
    const onAdd = () => Toast('add');
    return {
      onAdd,
    };
  },
};

Edit Contact

<van-contact-card type="edit" :tel="tel" :name="name" @click="onEdit" />
import { ref } from 'vue';
import { Toast } from 'vant';

export default {
  setup() {
    const tel = ref('13000000000');
    const name = ref('John Snow');
    const onEdit = () => Toast('edit');

    return {
      tel,
      name,
      onEdit,
    };
  },
};

Uneditable

<van-contact-card
  type="edit"
  name="John Snow"
  tel="13000000000"
  :editable="false"
/>

API

Props

Attribute Description Type Default
type Can be set to edit string add
name Name string -
tel Phone string -
add-text Add card text string Add contact info

Events

Event Description Arguments
click Emitted when component is clicked event: MouseEvent

CSS Variables

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

Name Default Value Description
--van-contact-card-padding var(--van-padding-md) -
--van-contact-card-add-icon-size 40px -
--van-contact-card-add-icon-color var(--van-primary-color) -
--van-contact-card-value-line-height var(--van-line-height-md) -