mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 19:19:26 +08:00
优化 Tag 关闭的逻辑, #84
This commit is contained in:
parent
5c0fabe855
commit
e00a562ca9
@ -2,18 +2,25 @@ import React from 'react';
|
||||
const prefixCls = 'ant-tag';
|
||||
|
||||
class AntTag extends React.Component {
|
||||
destroy(e) {
|
||||
let node = React.findDOMNode(this);
|
||||
React.unmountComponentAtNode(node);
|
||||
node.parentNode.removeChild(node);
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
closed: false
|
||||
};
|
||||
}
|
||||
close(e) {
|
||||
this.setState({
|
||||
closed: true
|
||||
});
|
||||
this.props.onClose.call(this, e);
|
||||
}
|
||||
render() {
|
||||
let close = this.props.closable ?
|
||||
<i className="anticon anticon-cross" onClick={this.destroy.bind(this)}></i> : '';
|
||||
<i className="anticon anticon-cross" onClick={this.close.bind(this)}></i> : '';
|
||||
let colorClass = this.props.prefixCls + '-' + this.props.color;
|
||||
|
||||
return <div className={this.props.prefixCls + ' ' + colorClass}>
|
||||
return this.state.closed ? null : <div className={this.props.prefixCls + ' ' + colorClass}>
|
||||
<a className={this.props.prefixCls + '-text'} {...this.props} />
|
||||
{close}
|
||||
</div>;
|
||||
|
Loading…
Reference in New Issue
Block a user