我一直被困在一个问题上,从输入字段中获取输入文本字段。本质上,我想创建一个搜索功能来获取文本并进一步处理它。请参阅代码以获取信息,返回 div 在底部。
import React from 'react';
import ReactDOM from 'react-dom';
import { useState, useEffect } from 'react';
import { Input, InputGroup, Icon} from 'rsuite';
import { Button, IconButton, ButtonGroup, ButtonToolbar } from 'rsuite';
import './App.css';
import Search from './search.js';
// import default style
import 'rsuite/dist/styles/rsuite-default.css';
import { render } from 'react-dom';
const styles = {
marginBottom: 10
};
const center = {
padding: '25% 25% 25%'
}
class App extends React.Component {
constructor(props){
super(props);
this.handleInputChange = this.handleInputChange.bind(this);
this.state = {
inputValue: 'Nothing'
}
}
handleInputChange(event){;
this.setState({inputValue: event.target.value});
};
render(){
return (
<div >
<div style={center} >
<InputGroup style={styles}> <Input size="md" value={this.inputValue} onChange={(e) => this.handleInputChange(e)} /><InputGroup.Addon>
<Button appearance="default"><Icon icon="search" /></Button>
</InputGroup.Addon>
</InputGroup>
</div>
</div>
)
}
}
export default App;