drawer closeWithConfirm props
This commit is contained in:
parent
8df3da7d49
commit
68f3d86761
@ -11,7 +11,7 @@ group:
|
|||||||
|
|
||||||
# Drawer - 抽屉
|
# Drawer - 抽屉
|
||||||
|
|
||||||
与 Ant Design
|
通过 `Drawer.open(props)` 方法打开抽屉,无需预渲染,可在任意触发事件中使用,多层抽屉的实现也更为巧妙。
|
||||||
|
|
||||||
### 基础抽屉
|
### 基础抽屉
|
||||||
|
|
||||||
@ -69,3 +69,35 @@ export default () => (
|
|||||||
}}>Open drawer</Button>
|
}}>Open drawer</Button>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 关闭时提示
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
/**
|
||||||
|
* title: 关闭时提示
|
||||||
|
* desc: 更多参数请参考 `Modal.confirm`
|
||||||
|
*/
|
||||||
|
import React from 'react';
|
||||||
|
import { Button } from 'antd';
|
||||||
|
import Drawer from './index.tsx';
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<Button onClick={() => {
|
||||||
|
Drawer.open({
|
||||||
|
title: 'Basic Drawer',
|
||||||
|
content: ({ closeWithConfirm }) => {
|
||||||
|
closeWithConfirm({
|
||||||
|
title: '您确定关闭抽屉吗?'
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>Some contents...</p>
|
||||||
|
<p>Some contents...</p>
|
||||||
|
<p>Some contents...</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}>Open Drawer</Button>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
@ -84,7 +84,7 @@ export function Drawer(title: any, content: any): IDrawer {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawer = {
|
const drawer: any = {
|
||||||
open: (props: any) => {
|
open: (props: any) => {
|
||||||
render(
|
render(
|
||||||
false,
|
false,
|
||||||
@ -113,7 +113,7 @@ export function Drawer(title: any, content: any): IDrawer {
|
|||||||
if (!env.root) return;
|
if (!env.root) return;
|
||||||
if (drawer.closeWithConfirm) {
|
if (drawer.closeWithConfirm) {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '表单内容发生变化,确定不保存吗?',
|
title: drawer.closeWithConfirm === true ? '表单内容发生变化,确定不保存吗?' : drawer.closeWithConfirm.title,
|
||||||
okText: '确定',
|
okText: '确定',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk() {
|
onOk() {
|
||||||
|
Loading…
Reference in New Issue
Block a user