From 58bd830f40f5f31dbf6d58a5a9d274d900539946 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Tue, 18 Aug 2015 00:57:02 +0800 Subject: [PATCH] remove btnClick --- .../notification/demo/with-btn-onclose.md | 21 +++++++++++-------- components/notification/demo/with-btn.md | 15 +++++++------ components/notification/index.jsx | 16 ++++++-------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/components/notification/demo/with-btn-onclose.md b/components/notification/demo/with-btn-onclose.md index 3b4bb237e2..f51664c7fb 100644 --- a/components/notification/demo/with-btn-onclose.md +++ b/components/notification/demo/with-btn-onclose.md @@ -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 = ; - var openNotification = function() { + var key='open'+Date.now(); + var btnClick = function() { + // 自定义按钮关闭时的业务处理 + console.log("我被自定义的关闭按钮关闭了!"); + // 隐藏提醒框 + notification.close(key); + }; + var btn = ; notification.open({ message: "这是标题", description: "这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案", btn: btn, - btnClose: close, + key:key, onClose: onClose }); }; diff --git a/components/notification/demo/with-btn.md b/components/notification/demo/with-btn.md index 985e966db6..dae783c4b8 100644 --- a/components/notification/demo/with-btn.md +++ b/components/notification/demo/with-btn.md @@ -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 = ; - var openNotification = function() { + var key='open'+Date.now(); + var btnClick = function() { + // 隐藏提醒框 + notification.close(key); + }; + var btn = ; notification.open({ message: "这是标题", description: "这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案", btn: btn, + key: key, btnClose: btnClick, onClose: close }); diff --git a/components/notification/index.jsx b/components/notification/index.jsx index 55d093e825..c151cec100 100644 --- a/components/notification/index.jsx +++ b/components/notification/index.jsx @@ -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:

{args.message}

{args.description}

- + {args.btn}
, duration: duration, closable: true, onClose: args.onClose, - key: key, + key: args.key, style: {} }); }