antd modal 拖动
时间: 2023-08-08 15:09:42 浏览: 120
要实现antd Modal的拖动功能,可以使用react-draggable库来实现。
首先,安装react-draggable库:
```bash
npm install react-draggable
```
然后,在Modal组件中引入react-draggable,并将Modal包裹在Draggable组件中:
```jsx
import React from 'react';
import { Modal } from 'antd';
import Draggable from 'react-draggable';
class DraggableModal extends React.Component {
render() {
return (
<Draggable>
<Modal {...this.props} />
</Draggable>
);
}
}
```
最后,使用DraggableModal组件替换antd的Modal组件即可:
```jsx
<DraggableModal
title="Basic Modal"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</DraggableModal>
```
这样就可以实现antd Modal的拖动功能了。
阅读全文