mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
update alert component
This commit is contained in:
parent
e4b9ce0f6e
commit
706caa855f
@ -9,12 +9,6 @@
|
||||
````jsx
|
||||
var Alert = require('antd/lib/alert');
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="success"
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-basic'));
|
||||
React.render(<Alert message="警告提示的文案" type="success" />
|
||||
, document.getElementById('components-alert-demo-basic'));
|
||||
````
|
||||
|
@ -9,13 +9,20 @@
|
||||
````jsx
|
||||
var Alert = require('antd/lib/alert');
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="success"
|
||||
closable="true"
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-closable'));
|
||||
var onClose = function(e) {
|
||||
console.log(e, '我要被关闭啦!');
|
||||
};
|
||||
|
||||
React.render(<div>
|
||||
<Alert message="警告提示的文案"
|
||||
type="warn"
|
||||
closable
|
||||
onClose={onClose} />
|
||||
<Alert message="警告提示的标题"
|
||||
description="警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案"
|
||||
type="error"
|
||||
closable
|
||||
onClose={onClose} />
|
||||
</div>, document.getElementById('components-alert-demo-closable'));
|
||||
````
|
||||
|
||||
|
@ -11,12 +11,6 @@ var Alert = require('antd/lib/alert');
|
||||
var link = <a href="javascript:;">不再提醒</a>
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="info"
|
||||
closeText={link}
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-close-type'));
|
||||
<Alert message="警告提示的文案" type="info" closeText={link} />
|
||||
, document.getElementById('components-alert-demo-close-type'));
|
||||
````
|
||||
|
@ -9,28 +9,20 @@
|
||||
````jsx
|
||||
var Alert = require('antd/lib/alert');
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="success"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="info"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍"
|
||||
type="warn"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="error"
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-description'));
|
||||
React.render(<div>
|
||||
<Alert message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="success" />
|
||||
<Alert message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="info" />
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍"
|
||||
type="warn" />
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
description="警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍警告提示的辅助性文字介绍"
|
||||
type="error" />
|
||||
</div>, document.getElementById('components-alert-demo-description'));
|
||||
````
|
||||
|
@ -1,33 +0,0 @@
|
||||
# 回调函数
|
||||
|
||||
- order: 5
|
||||
|
||||
警告提示被关闭时触发的回调函数,必须设置`closable="true"`。
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
var Alert = require('antd/lib/alert');
|
||||
|
||||
var onClose = function(){
|
||||
console.log('我要被关闭啦!');
|
||||
}
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="warn"
|
||||
closable="true"
|
||||
onClose={onClose}
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的标题"
|
||||
description="警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案警告提示的文案"
|
||||
type="error"
|
||||
closable="true"
|
||||
onClose={onClose}
|
||||
/>
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-onclose'));
|
||||
````
|
@ -9,24 +9,11 @@
|
||||
````jsx
|
||||
var Alert = require('antd/lib/alert');
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="success"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案警告提示的文案"
|
||||
type="info"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案"
|
||||
type="warn"
|
||||
/>
|
||||
<Alert
|
||||
message="警告提示的文案警告提示的文案"
|
||||
type="error"
|
||||
/>
|
||||
</div>,
|
||||
React.render(<div>
|
||||
<Alert message="警告提示的文案" type="success" />
|
||||
<Alert message="警告提示的文案警告提示的文案" type="info" />
|
||||
<Alert message="警告提示的文案" type="warn" />
|
||||
<Alert message="警告提示的文案警告提示的文案" type="error" />
|
||||
</div>,
|
||||
document.getElementById('components-alert-demo-style'));
|
||||
````
|
||||
|
@ -2,21 +2,26 @@ import React from 'react';
|
||||
|
||||
export default React.createClass({
|
||||
getDefaultProps() {
|
||||
return {prefixCls: 'ant-alert'};
|
||||
return {
|
||||
prefixCls: 'ant-alert'
|
||||
};
|
||||
},
|
||||
getInitialState () {
|
||||
return {display: 'block'};
|
||||
getInitialState() {
|
||||
return {
|
||||
display: 'block'
|
||||
};
|
||||
},
|
||||
handleClose () {
|
||||
handleClose(e) {
|
||||
if (this.props.onClose) {
|
||||
this.props.onClose();
|
||||
this.props.onClose.call(this, e);
|
||||
}
|
||||
this.setState({
|
||||
display: 'none'
|
||||
});
|
||||
},
|
||||
render () {
|
||||
var iconClass = this.props.description ? 'ant-alert-with-description-icon anticon-' : 'ant-alert-icon anticon-';
|
||||
var iconClass = this.props.description ?
|
||||
'ant-alert-with-description-icon anticon-' : 'ant-alert-icon anticon-';
|
||||
switch (this.props.type) {
|
||||
case 'success':
|
||||
iconClass += 'check-circle';
|
||||
@ -32,7 +37,7 @@ export default React.createClass({
|
||||
iconClass += 'default';
|
||||
}
|
||||
if (this.props.description) {
|
||||
let close = this.props.closable === 'true' ?
|
||||
let close = this.props.closable ?
|
||||
<a onClick={this.handleClose} className={'ant-alert-with-description-close-icon'}><span
|
||||
className='ant-alert-with-description-close-icon-x'></span></a> : '';
|
||||
return (
|
||||
@ -54,7 +59,7 @@ export default React.createClass({
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
let close = this.props.closable === 'true' ?
|
||||
let close = this.props.closable ?
|
||||
<a onClick={this.handleClose} className={'ant-alert-close-icon'}>
|
||||
<span className='ant-alert-close-icon-x'></span>
|
||||
</a> : '';
|
||||
|
@ -10,6 +10,7 @@
|
||||
## 何时使用
|
||||
|
||||
- 当系统需要向用户显示警告的信息时。
|
||||
- 始终展现,不会自动消失,用户可以点击关闭。
|
||||
|
||||
## API
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user