

---
name: Notification 通知
route: /notification
parent: 组件
menu: 反馈
---
import { Playground, Props } from 'docz'
import  notification  from '../components/notification'
import  Button  from '../components/button'


# Notification 通知
>提示: 展开代码编辑器可以在线编辑，实时生效

## 基础用法

<Playground>
  <Button onClick={()=>notification.info('我是标题','我是说明信息')} >信息提示</Button>
  <Button onClick={()=>notification.info('我是标题','我是说明信息',3000,true)} >信息提示，显示进度条</Button>
  <Button onClick={()=>notification.error('我是标题','我是说明信息')} >错误提示</Button>
  <Button onClick={()=>notification.success('我是标题','我是说明信息')} >成功提示</Button>
  <Button onClick={()=>notification.warning('我是标题','我是说明信息')} >警告提示</Button>
</Playground>

## 样式2

<Playground>
  <Button onClick={()=>notification.plain('我是标题我是标题我是标题我是标题我是标题我是标题','我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息')} >信息提示</Button>
  <Button onClick={()=>notification.info2('我是标题我是标题我是标题我是标题我是标题我是标题','我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息我是说明信息')} >信息提示</Button>
  <Button onClick={()=>notification.error2('我是标题','我是说明信息')} >错误提示</Button>
    <Button onClick={()=>notification.success2('我是标题','我是说明信息')} >成功提示</Button>
    <Button onClick={()=>notification.warning2('我是标题','我是说明信息')} >警告提示</Button>
</Playground>


## 指定消息时长
notification方法第二个参数可以传入数字（毫秒数）
<Playground>
  <Button onClick={()=>notification.success('指定时长', '0.5s后消失',500)}>定消息时长</Button>
  
</Playground>

## 代码关闭
同`message`的用法，调用`notificatin`会返回一个函数，调用该函数取消该条消息
<Playground>
  <Button onClick={()=>window.handle = notification.info('代码关闭','代码关闭',50000)}>触发消息</Button>
  <Button onClick={()=>window.handle()}>代码关闭</Button>
  
</Playground>


## API

```typescript jsx
notification.info(title, desc, timeout = 3000, showProgress = false)
```