From ac85f82f095cd72e88ec24e7da9e7cabfffc3af6 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 30 Dec 2021 21:22:28 +0800 Subject: [PATCH] docs(Search): update action slot demo (#10133) --- packages/vant/src/search/README.md | 20 +++++++++++++++++++- packages/vant/src/search/README.zh-CN.md | 20 +++++++++++++++++++- packages/vant/src/search/demo/index.vue | 3 ++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/vant/src/search/README.md b/packages/vant/src/search/README.md index 8a5cf6a1e..a03a5fc0a 100644 --- a/packages/vant/src/search/README.md +++ b/packages/vant/src/search/README.md @@ -107,11 +107,29 @@ Use `action` slot to custom right button, `cancel` event will no longer be Emitt @search="onSearch" > ``` +```js +import { ref } from 'vue'; +import { Toast } from 'vant'; + +export default { + setup() { + const value = ref(''); + const onSearch = (val) => Toast(val); + const onClickButton = () => Toast(value.value); + return { + value, + onSearch, + onClickButton, + }; + }, +}; +``` + ## API ### Props diff --git a/packages/vant/src/search/README.zh-CN.md b/packages/vant/src/search/README.zh-CN.md index 44b5c609e..9d70a0d38 100644 --- a/packages/vant/src/search/README.zh-CN.md +++ b/packages/vant/src/search/README.zh-CN.md @@ -119,11 +119,29 @@ export default { @search="onSearch" > ``` +```js +import { ref } from 'vue'; +import { Toast } from 'vant'; + +export default { + setup() { + const value = ref(''); + const onSearch = (val) => Toast(val); + const onClickButton = () => Toast(value.value); + return { + value, + onSearch, + onClickButton, + }; + }, +}; +``` + ## API ### Props diff --git a/packages/vant/src/search/demo/index.vue b/packages/vant/src/search/demo/index.vue index 44cc56ecd..f8007a0c2 100644 --- a/packages/vant/src/search/demo/index.vue +++ b/packages/vant/src/search/demo/index.vue @@ -34,6 +34,7 @@ const value6 = ref(''); const onSearch = (val: string) => Toast(val); const onCancel = () => Toast(t('cancel')); +const onClickButton = () => Toast(value6.value);