ant-design/components/notification/demo/with-btn.md
偏右 b531de3fee
Upgrade dev deps and fix lints (#8358)
* upgrade devDeps and fix lint

* Fix stylelint problems
2017-11-29 21:00:16 +08:00

952 B

order title
3
zh-CN en-US
自定义按钮 Custom close button

zh-CN

自定义关闭按钮的样式和文字。

en-US

To customize the style or font of the close button.

import { Button, notification } from 'antd';

const close = () => {
  console.log('Notification was closed. Either the close button was clicked or duration time elapsed.');
};

const openNotification = () => {
  const key = `open${Date.now()}`;
  const btn = (
    <Button type="primary" size="small" onClick={() => notification.close(key)}>
      Confirm
    </Button>
  );
  notification.open({
    message: 'Notification Title',
    description: 'A function will be be called after the notification is closed (automatically after the "duration" time of manually).',
    btn,
    key,
    onClose: close,
  });
};

ReactDOM.render(
  <Button type="primary" onClick={openNotification}>
    Open the notification box
  </Button>
, mountNode);