Commit 0f5f9299 authored by XieZhiXiong's avatar XieZhiXiong

chore: 增强判断

parent 875e074c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-05-28 14:30:06 * @Date: 2021-05-28 14:30:06
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-08 16:27:02 * @LastEditTime: 2021-07-03 14:02:39
* @Description: 搜索组件 * @Description: 搜索组件
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
...@@ -49,12 +49,12 @@ const MySearch: React.FC<IProps> = (props: IProps) => { ...@@ -49,12 +49,12 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
} }
}, [value]); }, [value]);
const handleChange = (e) => { const handleChange = (next: string) => {
if (!('value' in props)) { if (!('value' in props)) {
setKeyword(e.target.value); setKeyword(next);
} }
if (onChange) { if (onChange) {
onChange(e.target.value); onChange(next);
} }
}; };
...@@ -65,9 +65,9 @@ const MySearch: React.FC<IProps> = (props: IProps) => { ...@@ -65,9 +65,9 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
}; };
const handleReset = () => { const handleReset = () => {
onChange(''); handleChange('');
if (searchOnResetAction) { if (searchOnResetAction) {
onSearch(''); handleSearch('');
} }
if (onReset) { if (onReset) {
onReset(); onReset();
...@@ -79,7 +79,7 @@ const MySearch: React.FC<IProps> = (props: IProps) => { ...@@ -79,7 +79,7 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
<Input.Search <Input.Search
style={{ width: '200px', marginRight: 16 }} style={{ width: '200px', marginRight: 16 }}
value={keyword} value={keyword}
onChange={handleChange} onChange={(e) => handleChange(e.target.value)}
onSearch={handleSearch} onSearch={handleSearch}
{...rest} {...rest}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment