mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
Add component tag
This commit is contained in:
parent
b6fe8021f8
commit
6344e9151b
17
components/tag/demo/basic.md
Normal file
17
components/tag/demo/basic.md
Normal file
@ -0,0 +1,17 @@
|
||||
# 基本
|
||||
|
||||
- order: 0
|
||||
|
||||
标签。
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
var Tag = antd.Tag;
|
||||
|
||||
React.render(<div>
|
||||
<Tag>标签一</Tag>
|
||||
<Tag closable>标签二</Tag>
|
||||
<Tag>标签三</Tag>
|
||||
</div>, document.getElementById('components-tag-demo-basic'));
|
||||
````
|
29
components/tag/index.jsx
Normal file
29
components/tag/index.jsx
Normal file
@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
const prefixCls = 'ant-tag';
|
||||
|
||||
class AntTag extends React.Component {
|
||||
destroy() {
|
||||
let node = React.findDOMNode(this);
|
||||
React.unmountComponentAtNode(node);
|
||||
node.parentNode.removeChild(node);
|
||||
this.props.onClose.call(this);
|
||||
}
|
||||
render() {
|
||||
var close = this.props.closable ?
|
||||
<i className="anticon anticon-cross" onClick={this.destroy.bind(this)}></i> : '';
|
||||
return <div className={this.props.prefixCls}>
|
||||
<span className={this.props.prefixCls + '-text'}>
|
||||
{this.props.children}
|
||||
</span>
|
||||
{close}
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
AntTag.defaultProps = {
|
||||
prefixCls: prefixCls,
|
||||
closable: false,
|
||||
onClose: function() {}
|
||||
};
|
||||
|
||||
export default AntTag;
|
1
index.js
1
index.js
@ -19,6 +19,7 @@ var antd = {
|
||||
Switch: require('./components/switch'),
|
||||
Checkbox: require('./components/checkbox'),
|
||||
Table: require('./components/table'),
|
||||
Tag: require('./components/tag'),
|
||||
Collapse: require('./components/collapse'),
|
||||
message: require('./components/message'),
|
||||
Slider: require('./components/slider'),
|
||||
|
Loading…
Reference in New Issue
Block a user