UNPKG

zent

Version:

一套前端设计语言和基于React的实现

39 lines (33 loc) 830 B
import PropTypes from 'prop-types'; import React, { Component, PureComponent } from 'react'; class Option extends (PureComponent || Component) { constructor(props) { super(props); this.optionClickHandler = this.optionClickHandler.bind(this); } optionClickHandler(ev) { this.props.onClick(ev, this.props.cid); } render() { const { className, text, value } = this.props; return ( <span value={value} className={className} onClick={this.optionClickHandler} onMouseEnter={this.props.onMouseEnter} > {text} </span> ); } } Option.propTypes = { prefixCls: PropTypes.string, cid: PropTypes.string, value: PropTypes.any, text: PropTypes.any, placeholder: PropTypes.string, onMouseEnter: PropTypes.func }; export default Option;