remove btnClick

pull/148/head
yiminghe 10 years ago
parent a15e428155
commit 58bd830f40

@ -9,26 +9,29 @@
````jsx
var notification = require('antd/lib/notification');
var close = function(key) {
// 自定义按钮关闭时的业务处理
console.log("我被自定义的关闭按钮关闭了!");
// 隐藏提醒框
notification.close(key);
};
var onClose = function() {
// 默认按钮关闭时的业务处理
console.log("我被默认的关闭按钮关闭了!");
};
var btn = <button className="ant-btn ant-btn-primary ant-btn-sm">自定义关闭按钮并触发回调函数</button>;
var openNotification = function() {
var key='open'+Date.now();
var btnClick = function() {
// 自定义按钮关闭时的业务处理
console.log("我被自定义的关闭按钮关闭了!");
// 隐藏提醒框
notification.close(key);
};
var btn = <button className="ant-btn ant-btn-primary ant-btn-sm"
onClick={btnClick}
>自定义关闭按钮并触发回调函数</button>;
notification.open({
message: "这是标题",
description: "这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案",
btn: btn,
btnClose: close,
key:key,
onClose: onClose
});
};

@ -9,22 +9,25 @@
````jsx
var notification = require('antd/lib/notification');
var btnClick = function(key) {
// 隐藏提醒框
notification.close(key);
};
var close = function(){
console.log('我被默认的关闭按钮关闭了!');
}
var btn = <button onClick={btnClick} className="ant-btn ant-btn-primary ant-btn-sm">自定义关闭按钮</button>;
var openNotification = function() {
var key='open'+Date.now();
var btnClick = function() {
// 隐藏提醒框
notification.close(key);
};
var btn = <button className="ant-btn ant-btn-primary ant-btn-sm"
onClick={btnClick}
>自定义关闭按钮并触发回调函数</button>;
notification.open({
message: "这是标题",
description: "这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案",
btn: btn,
key: key,
btnClose: btnClick,
onClose: close
});

@ -5,14 +5,11 @@ import React from 'react';
let top = 24;
let notificationInstance;
function callback(key, btnCose) {
if (btnCose) {
btnCose(key);
}
}
function getNotificationInstance() {
notificationInstance = notificationInstance || Notification.newInstance({
if (notificationInstance) {
return notificationInstance;
}
notificationInstance = Notification.newInstance({
prefixCls: 'ant-notification',
style: {
top: top,
@ -78,20 +75,19 @@ function notice(args) {
style: {}
});
} else {
let key = 'manual' + new Date().getTime();
getNotificationInstance().notice({
content: <div>
<p className={prefixCls + 'message'}>{args.message}</p>
<p className={prefixCls + 'description'}>{args.description}</p>
<span onClick={callback.bind(null, key, args.btnClose)} className={prefixCls + 'btn'}>
<span className={prefixCls + 'btn'}>
{args.btn}
</span>
</div>,
duration: duration,
closable: true,
onClose: args.onClose,
key: key,
key: args.key,
style: {}
});
}

Loading…
Cancel
Save