|
|
@ -9,11 +9,13 @@ |
|
|
|
````jsx |
|
|
|
var notification = require('antd/lib/notification'); |
|
|
|
|
|
|
|
var key = 'someKeyString'; |
|
|
|
|
|
|
|
var close = function() { |
|
|
|
// 自定义按钮关闭时的业务处理 |
|
|
|
console.log("我被自定义的关闭按钮关闭了!"); |
|
|
|
// 隐藏提醒框 |
|
|
|
notification.close('singleKey1'); |
|
|
|
notification.close(key); |
|
|
|
}; |
|
|
|
|
|
|
|
var onClose = function() { |
|
|
@ -24,18 +26,17 @@ var onClose = function() { |
|
|
|
var btn = <button onClick={close} className="ant-btn ant-btn-primary ant-btn-sm">自定义关闭按钮并触发回调函数</button>; |
|
|
|
|
|
|
|
var openNotification = function() { |
|
|
|
var key = 'manual' + new Date().getTime(); |
|
|
|
var args = { |
|
|
|
message: "这是标题", |
|
|
|
description: "这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案", |
|
|
|
btn: btn, |
|
|
|
key: 'singleKey1', |
|
|
|
key: key, |
|
|
|
onClose: onClose |
|
|
|
}; |
|
|
|
notification.open(args); |
|
|
|
}; |
|
|
|
|
|
|
|
React.render( |
|
|
|
<button className="ant-btn ant-btn-primary" onClick={openNotification}>点击自定义的按钮触发回调函数</button> |
|
|
|
<button className="ant-btn ant-btn-primary" onClick={openNotification}>打开通知提醒框</button> |
|
|
|
, document.getElementById('components-notification-demo-with-btn-onclose')); |
|
|
|
```` |
|
|
|