From 25634382f630b620214394524e19f005fee29b55 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 15 Dec 2020 14:48:19 +0800 Subject: [PATCH] docs(ContactCard): use composition api --- src/contact-card/README.md | 25 ++++++----- src/contact-card/README.zh-CN.md | 25 ++++++----- src/contact-card/demo/index.vue | 71 ++++++++++++++++++-------------- 3 files changed, 67 insertions(+), 54 deletions(-) diff --git a/src/contact-card/README.md b/src/contact-card/README.md index 8d6090e2b..8f6ca3233 100644 --- a/src/contact-card/README.md +++ b/src/contact-card/README.md @@ -42,21 +42,24 @@ export default { ``` ```js +import { reactive } from 'vue'; import { Toast } from 'vant'; export default { - data() { - return { - currentContact: { - name: 'John Snow', - tel: '13000000000', - }, - }; - }, - methods: { - onEdit() { + setup() { + const currentContact = reactive({ + name: 'John Snow', + tel: '13000000000', + }); + + const onEdit = () => { Toast('edit'); - }, + }; + + return { + onEdit, + currentContact, + }; }, }; ``` diff --git a/src/contact-card/README.zh-CN.md b/src/contact-card/README.zh-CN.md index 33fbfdc41..e0baf255c 100644 --- a/src/contact-card/README.zh-CN.md +++ b/src/contact-card/README.zh-CN.md @@ -46,21 +46,24 @@ export default { ``` ```js +import { reactive } from 'vue'; import { Toast } from 'vant'; export default { - data() { - return { - currentContact: { - name: '张三', - tel: '13000000000', - }, + setup() { + const currentContact = reactive({ + name: '张三', + tel: '13000000000', + }); + + const onEdit = () => { + Toast('edit'); + }; + + return { + onEdit, + currentContact, }; - }, - methods: { - onEdit() { - Toast('编辑'); - }, }, }; ``` diff --git a/src/contact-card/demo/index.vue b/src/contact-card/demo/index.vue index be226853c..1762b86c1 100644 --- a/src/contact-card/demo/index.vue +++ b/src/contact-card/demo/index.vue @@ -22,44 +22,51 @@ -