mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +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 |
- |