Commit 0f5f9299 authored by XieZhiXiong's avatar XieZhiXiong

chore: 增强判断

parent 875e074c
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-05-28 14:30:06
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-08 16:27:02
* @LastEditTime: 2021-07-03 14:02:39
* @Description: 搜索组件
*/
import React, { useState, useEffect } from 'react';
......@@ -49,12 +49,12 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
}
}, [value]);
const handleChange = (e) => {
const handleChange = (next: string) => {
if (!('value' in props)) {
setKeyword(e.target.value);
setKeyword(next);
}
if (onChange) {
onChange(e.target.value);
onChange(next);
}
};
......@@ -65,9 +65,9 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
};
const handleReset = () => {
onChange('');
handleChange('');
if (searchOnResetAction) {
onSearch('');
handleSearch('');
}
if (onReset) {
onReset();
......@@ -79,7 +79,7 @@ const MySearch: React.FC<IProps> = (props: IProps) => {
<Input.Search
style={{ width: '200px', marginRight: 16 }}
value={keyword}
onChange={handleChange}
onChange={(e) => handleChange(e.target.value)}
onSearch={handleSearch}
{...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