From 9277089b30b2d96fe2e0d1d564d385ec2f201b9b Mon Sep 17 00:00:00 2001 From: paranoidjk Date: Thu, 16 Mar 2017 09:53:35 +0800 Subject: [PATCH] feat(Modal): add close api. close #995 (#998) --- .../__snapshots__/demo.test.web.js.snap | 2 +- components/modal/alert.web.tsx | 8 +++++++- components/modal/demo/alert.md | 17 ++++++++++++----- components/modal/index.en-US.md | 10 +++++++++- components/modal/index.zh-CN.md | 10 +++++++++- components/modal/operation.web.tsx | 4 ++++ components/modal/prompt.web.tsx | 4 ++++ 7 files changed, 46 insertions(+), 9 deletions(-) diff --git a/components/modal/__tests__/__snapshots__/demo.test.web.js.snap b/components/modal/__tests__/__snapshots__/demo.test.web.js.snap index 95119d5c1e..e29091cfae 100644 --- a/components/modal/__tests__/__snapshots__/demo.test.web.js.snap +++ b/components/modal/__tests__/__snapshots__/demo.test.web.js.snap @@ -12,7 +12,7 @@ exports[`renders ./components/modal/demo/alert.md correctly 1`] = ` role="button" > - 自定义按钮 + 自定义按钮
{}, + }; } const prefixCls = 'am-modal'; @@ -53,4 +55,8 @@ export default function (...args) {
{content}
, div ); + + return { + close, + }; } diff --git a/components/modal/demo/alert.md b/components/modal/demo/alert.md index e1f5596050..87ab65b594 100644 --- a/components/modal/demo/alert.md +++ b/components/modal/demo/alert.md @@ -18,14 +18,21 @@ import { Modal, Button, WhiteSpace, WingBlank, Toast } from 'antd-mobile'; const alert = Modal.alert; +const showAlert = () => { + const alertInstance = alert('删除', '确定删除么???', [ + { text: 'Cancel', onPress: () => console.log('cancel'), style: 'default' }, + { text: 'OK', onPress: () => console.log('ok'), style: { fontWeight: 'bold' } }, + ]); + setTimeout(() => { + // 可以调用close方法以在外部close + alertInstance.close(); + }, 1000); +}; + const App = () => ( - +