import React, { Component } from "react";
import { withRouter } from 'react-router-dom'
import "./index.scss";
class Header extends Component {
constructor(props) {
super(props);
this.state = {
inputValue: "",
};
}
onChange=(e)=> {
this.setState({
inputValue:e.target.value
})
}
onKeyup=(e)=> {
if(e.keyCode === 13) {
this.props.history.push("/history",{active:"toggle",index:1})
}
}
render() {
return (
<div className="header">
<div className="search-wrapper">
<span className="search-icon"></span>
<input
onChange={(e) => {this.onChange(e)}}
onKeyUp={this.onKeyup}
className="search"
placeholder="搜索"
/>
</div>
<div className="operate-wapper">
<img src="/static/images/header/question.png" />
<img src="/static/images/header/setting.png" />
<img src="/static/images/header/bell.png" />
</div>
</div>
);
}
}
export default withRouter(Header);
React监听键盘事件
最新推荐文章于 2024-09-22 07:13:41 发布