1 | import React from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 |
|
4 | const propTypes = {
|
5 | active:PropTypes.bool,
|
6 | value:PropTypes.string,
|
7 | }
|
8 |
|
9 | const defaultProps = {
|
10 | active:false
|
11 | }
|
12 |
|
13 | class Tab extends React.Component{
|
14 |
|
15 | click=()=>{
|
16 | this.props.tabClick(this.props.value);
|
17 | this.props.onClick&&this.props.onClick(this.props.value);
|
18 | }
|
19 |
|
20 | render(){
|
21 | let { clsfix,children,active,value } = this.props;
|
22 | let classes = `${clsfix}-item`;
|
23 | if(active)classes += ' active'
|
24 | return (
|
25 | <span className={classes} onClick={this.click} value={value}>
|
26 | { children }
|
27 | </span>
|
28 | )
|
29 | }
|
30 | }
|
31 |
|
32 |
|
33 | Tab.propTypes = propTypes;
|
34 | Tab.defaultProps = defaultProps;
|
35 |
|
36 | export default Tab; |
\ | No newline at end of file |