diff --git a/src/search/README.md b/src/search/README.md index e3bb949f4..29f916947 100644 --- a/src/search/README.md +++ b/src/search/README.md @@ -148,6 +148,7 @@ Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Search | Name | Description | Attribute | Return value | | ----- | ------------------- | --------- | ------------ | | focus | Trigger input focus | - | - | +| blur | Trigger input blur | - | - | ### Slots diff --git a/src/search/README.zh-CN.md b/src/search/README.zh-CN.md index 63414ddff..123cf4d84 100644 --- a/src/search/README.zh-CN.md +++ b/src/search/README.zh-CN.md @@ -164,6 +164,7 @@ export default { | 方法名 | 说明 | 参数 | 返回值 | | ------ | -------------- | ---- | ------ | | focus | 获取输入框焦点 | - | - | +| blur | 取消输入框焦点 | - | - | ### Slots diff --git a/src/search/index.js b/src/search/index.js index 62d3a667d..c16f5b557 100644 --- a/src/search/index.js +++ b/src/search/index.js @@ -88,6 +88,12 @@ export default createComponent({ } }; + const blur = () => { + if (filedRef.value) { + filedRef.value.blur(); + } + }; + const fieldPropNames = [ 'leftIcon', 'rightIcon', @@ -116,7 +122,7 @@ export default createComponent({ ); }; - useExpose({ focus }); + useExpose({ focus, blur }); return () => (