


## 常用API
Message组件才用js调用的方式来使用
组件提供了六个常用静态方法，调用后返回的是该消息实例的关闭函数。

- message.success(params)
- message.alert(params)
- message.info(params)
- message.question(params)
- message.loading(params)

params可为两种类型
### 一种是params为字符串的类型
当传入的是字符串

``` javascript
Message.info('test');
Message.question('test');
Message.success('test');
Message.alert('test');
```


### 一种是params为对象的类型
params 为对象时有以下几种参数
| 属性 | 说明 | 类型 | 默认值 |
| :--- | :--- | :--- | :--- |
|content| 提示内容 | React.Element or String | -|
|duration | 自动关闭的延时，单位秒| number | 1.5 （loading的默认是0，即不自动关闭）|
|closable | 是否有关闭按钮| bool | false |
|onClose | 消息结束的回调| func | noop |
|direction | 消息出现的方向| string | top |



``` javascript

//自定义内容， 设置展示关闭按钮， 以及监听消息结束事件
Message.info({
  content: (
    <ul>
      <li>自定义内容</li>
      <li>自定义内容</li>
      <li>自定义内容</li>
      <li>自定义内容</li>
    </ul>
  ),
  closable: true,
  onClose: () => {
    this.setState({
      visible9: true
    });
  },
  direction: 'left'
});

//loading的比较特殊， 这边存在用户自己去关闭的场景
//返回该message的api 对象
let message = Message.loading('loading, 自己去关闭');
setTimeout(() => {
    message.close();
}, 5000);

```



## message调用后回调对象API：
目前调用message方法，只会返回带有close方法的对象
### 关闭方法，关闭调用的messgeItem
- message.close()

```javascript
let message = Message.info('loading, 自己去关闭');
setTimeout(() => {
    message.close();
}, 5000);

```

---


## 全局API：

### 全局配置方法
- Message.config(options)



```javascript
Message.config({
  direction: 'center',  // 可选的值为'top'||'center'||'left'||'right'||'bottom'
  duration: 2,
  zIndex: 4001,
});
```

|参数 | 说明 | 类型 | 默认值|
| :--- | :--- | :--- | :--- |
|direction | 消息的展现位置 |String |'top'|
|duration|  默认自动关闭延时，单位秒  |Number | 2|
|zIndex|  消息展示zIndex  |Number | 4000 |

### 全局销毁方法
- Message.destroy()
