Benjy Cui
9 years ago
7 changed files with 95 additions and 26 deletions
@ -1,9 +0,0 @@ |
|||
"use strict"; |
|||
const react_1 = require('react'); |
|||
const splitObject_1 = require('../_util/splitObject'); |
|||
Object.defineProperty(exports, "__esModule", { value: true }); |
|||
exports.default = props => { |
|||
const [{ type, className = '' }, others] = splitObject_1.default(props, ['type', 'className']); |
|||
let className2 = `${className} anticon anticon-${type}`.trim(); |
|||
return <i className={className2} {...others}/>; |
|||
}; |
@ -1,17 +1,25 @@ |
|||
--- |
|||
order: 2 |
|||
title: 修改延时 |
|||
title: |
|||
zh-CN: 修改延时 |
|||
en-US: Customize duration |
|||
--- |
|||
|
|||
## zh-CN |
|||
|
|||
自定义时长 `10s`,默认时长为 `1.5s`。 |
|||
|
|||
## en-US |
|||
|
|||
Customize message display duration from default `1.5s` to `10s`. |
|||
|
|||
````jsx |
|||
import { message, Button } from 'antd'; |
|||
|
|||
const success = function () { |
|||
message.success('这是一条成功的提示,并将于10秒后消失', 10); |
|||
message.success('This is a prompt message for success, and it will disappear in 10 seconds', 10); |
|||
}; |
|||
|
|||
ReactDOM.render(<Button onClick={success}>自定义时长提示</Button> |
|||
ReactDOM.render(<Button onClick={success}>Customized display duration</Button> |
|||
, mountNode); |
|||
```` |
|||
|
@ -1,17 +1,25 @@ |
|||
--- |
|||
order: 0 |
|||
title: 普通提示 |
|||
title: |
|||
zh-CN: 普通提示 |
|||
en-US: Normal prompt |
|||
--- |
|||
|
|||
## zh-CN |
|||
|
|||
信息提醒反馈。 |
|||
|
|||
## en-US |
|||
|
|||
Normal messages as feedbacks. |
|||
|
|||
````jsx |
|||
import { message, Button } from 'antd'; |
|||
|
|||
const info = function () { |
|||
message.info('这是一条普通的提醒'); |
|||
message.info('This is a normal message'); |
|||
}; |
|||
|
|||
ReactDOM.render(<Button type="primary" onClick={info}>显示普通提醒</Button> |
|||
ReactDOM.render(<Button type="primary" onClick={info}>Display normal message</Button> |
|||
, mountNode); |
|||
```` |
|||
|
@ -1,19 +1,27 @@ |
|||
--- |
|||
order: 3 |
|||
title: 加载中 |
|||
title: |
|||
zh-CN: 加载中 |
|||
en-US: Message of loading |
|||
--- |
|||
|
|||
## zh-CN |
|||
|
|||
进行全局 loading,异步自行移除。 |
|||
|
|||
## en-US |
|||
|
|||
Display a global loading indicator, which is dismissed by itself asynchronously. |
|||
|
|||
````jsx |
|||
import { message, Button } from 'antd'; |
|||
|
|||
const success = function () { |
|||
let hide = message.loading('正在执行中...', 0); |
|||
// 异步手动移除 |
|||
let hide = message.loading('Action in progress..', 0); |
|||
// Dismiss manually and asynchronously |
|||
setTimeout(hide, 2500); |
|||
}; |
|||
|
|||
ReactDOM.render(<Button onClick={success}>显示加载中...</Button> |
|||
ReactDOM.render(<Button onClick={success}>Display a loading indicator</Button> |
|||
, mountNode); |
|||
```` |
|||
|
@ -0,0 +1,46 @@ |
|||
--- |
|||
category: Components |
|||
type: Presentation |
|||
noinstant: true |
|||
english: Message |
|||
--- |
|||
|
|||
Display global messages as feedbacks to user operations. |
|||
|
|||
## When To Use |
|||
|
|||
- To provide feedbacks such as success, warning, error etc. |
|||
- A message is displayed at top and center and will be dismissed automatically, as a non-interrupting light-weighted prompt. |
|||
|
|||
## API |
|||
|
|||
- `message.success(content, duration)` |
|||
- `message.error(content, duration)` |
|||
- `message.info(content, duration)` |
|||
- `message.warning(content, duration)` |
|||
- `message.warn(content, duration)` |
|||
- `message.loading(content, duration)` |
|||
|
|||
This components provides 4 static methods, with arguments as following: |
|||
|
|||
| Argument | Description | Type | Default | |
|||
|------------|------------------------------------|--------------------------|--------------| |
|||
| content | content of the message | React.Element or String | - | |
|||
| duration | time before auto-dismiss,in seconds | number | 1.5 | |
|||
|
|||
Methods for global configuration and destruction are also provided: |
|||
|
|||
- `message.config(options)` |
|||
- `message.destroy()` |
|||
|
|||
```js |
|||
message.config({ |
|||
top: 100, |
|||
duration: 2, |
|||
}); |
|||
``` |
|||
|
|||
| Argument | Description | Type | Default | |
|||
|------------|------------------------------------|--------------------------|-------------| |
|||
| top | distance to top | Number | 24px | |
|||
| duration | time before auto-dismiss,in seconds | Number | 1.5 | |
Loading…
Reference in new issue