vant/src/contact-card
neverland bd609e1df0
perf: add truthProp util (#8522)
* perf: add TruthyProp util

* chore: rename

* chore: upd
2021-04-14 10:26:21 +08:00
..
2021-03-09 15:39:26 +08:00
2021-03-09 15:39:26 +08:00
2021-03-08 17:14:55 +08:00
2021-04-08 09:57:55 +08:00
2021-03-17 16:14:18 +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"
  :name="currentContact.name"
  :tel="currentContact.tel"
  @click="onEdit"
/>
import { reactive } from 'vue';
import { Toast } from 'vant';

export default {
  setup() {
    const currentContact = reactive({
      name: 'John Snow',
      tel: '13000000000',
    });
    const onEdit = () => Toast('edit');

    return {
      onEdit,
      currentContact,
    };
  },
};

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

Less Variables

How to use: Custom Theme.

Name Default Value Description
@contact-card-padding @padding-md -
@contact-card-add-icon-size 40px -
@contact-card-add-icon-color @blue -
@contact-card-value-line-height @line-height-md -