modal.jsx
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*eslint-disable*/
import React, { PureComponent } from 'react';
import { Modal } from 'antd-mobile-v2';
export default class ModalBase extends PureComponent {
state = {
visible: this.props.visible,
}
closeModal = () => {
this.setState({ visible: false });
}
openModal = () => {
this.setState({ visible: true });
}
render() {
const { title, submitAction, content, cancelAction, ...others } = this.props;
return <>
<Modal
bodyStyle={{
height: '60vh',
}}
transparent
maskClosable={false}
destroyOnClose
title={title || ''}
footer={[
{ text: '取消', onPress: () => { typeof cancelAction === 'function' && cancelAction() } },
{ text: '确认', onPress: () => { typeof submitAction === 'function' && submitAction() } },
]}
{ ...others }
>
<div style={{ height: '100%' }}>
{
content
}
</div>
</Modal>
</>
}
}