import React, { Component } from 'react'; import './input.scss' import classnames from 'classnames' class Input extends Component { clearInput = () => { this.props.onChange('') } render() { let {type, placeholder} = this.props return ( <div className='custom-input-wrapper'> <input type={type} className={classnames('custom-input')} placeholder={placeholder} onChange={this.props.onChange} value={this.props.value} /> <i className={classnames('iconfont icondanseshixintubiao-3', { hide: this.props.value.length === 0 })} onClick={this.clearInput} /> </div> ); } } Input.defaultProps = {type: 'text', placeholder: ''} export default Input;