UNPKG

777 BJavaScriptView Raw
1import React from 'react';
2import PropTypes from 'prop-types';
3
4const propTypes = {
5 active:PropTypes.bool,//是否active
6 value:PropTypes.string,//唯一标示
7}
8
9const defaultProps = {
10 active:false
11}
12
13class 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
33Tab.propTypes = propTypes;
34Tab.defaultProps = defaultProps;
35
36export default Tab;
\No newline at end of file