From 31d63bc701890df3a487c2e7a5603b20fb50892f Mon Sep 17 00:00:00 2001 From: Yanghc Date: Mon, 7 Jan 2019 18:38:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20HeaderSearch=20=E7=9A=84?= =?UTF-8?q?=20onSearch=20=E5=9B=9E=E8=B0=83=20(#3227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复 HeaderSearch 的 onSearch 回调 修复 #3222 问题,在使用 HeaderSearch组件时,可以选择使用 `onSearch` 或者 `onChange ` 方法。 * 统一代码格式 --- src/components/HeaderSearch/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index 95d946c0..2c56fe38 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -11,6 +11,7 @@ export default class HeaderSearch extends PureComponent { className: PropTypes.string, placeholder: PropTypes.string, onSearch: PropTypes.func, + onChange: PropTypes.func, onPressEnter: PropTypes.func, defaultActiveFirstOption: PropTypes.bool, dataSource: PropTypes.array, @@ -22,6 +23,7 @@ export default class HeaderSearch extends PureComponent { defaultActiveFirstOption: false, onPressEnter: () => {}, onSearch: () => {}, + onChange: () => {}, className: '', placeholder: '', dataSource: [], @@ -61,10 +63,13 @@ export default class HeaderSearch extends PureComponent { }; onChange = value => { - const { onChange } = this.props; + const { onSearch, onChange } = this.props; this.setState({ value }); - if (onChange) { - onChange(value); + if (onSearch){ + onSearch(value); + } + if (onChange){ + onChange(value); } }; -- GitLab