index.jsx 649 字节
Newer Older
U
ustccjw 已提交
1 2
import React from 'react';
import Tooltip from 'rc-tooltip';
A
afc163 已提交
3

U
ustccjw 已提交
4
export default React.createClass({
A
afc163 已提交
5
  getDefaultProps() {
A
afc163 已提交
6
    return {
7 8 9 10
      prefixCls: 'ant-tooltip',
      placement: 'top',
      mouseEnterDelay: 0.1,
      mouseLeaveDelay: 0.1
A
afc163 已提交
11 12
    };
  },
A
afc163 已提交
13
  render() {
A
afc163 已提交
14
    let transitionName = ({
A
afc163 已提交
15 16 17 18 19
      top: 'zoom-down',
      bottom: 'zoom-up',
      left: 'zoom-right',
      right: 'zoom-left'
    })[this.props.placement];
A
afc163 已提交
20
    return (
A
afc163 已提交
21
      this.props.title ? <Tooltip transitionName={transitionName}
22 23
        overlay={this.props.title}
        {...this.props}>
A
afc163 已提交
24
        {this.props.children}
A
afc163 已提交
25
      </Tooltip> : this.props.children
A
afc163 已提交
26 27 28
    );
  }
});