Element ui关闭el-dialog
时间: 2023-09-07 16:16:03 浏览: 169
element ui 对话框el-dialog关闭事件详解
5星 · 资源好评率100%
要关闭Element UI的el-dialog,你可以在methods中添加一个函数来实现。例如,你可以在methods中添加一个名为closeForm的函数,然后在函数中设置dialogVisible为false,这样就可以关闭el-dialog了。具体代码如下所示:
```javascript
methods: {
closeForm() {
this.dialogVisible = false;
}
}
```
在el-dialog的footer中,你可以添加一个按钮,当点击该按钮时调用closeForm函数来关闭el-dialog。例如,你可以在el-dialog的footer中添加一个el-button,并设置@click事件为closeForm函数,如下所示:
```html
<span slot="footer" class="dialog-footer">
<el-button @click="closeForm">取消</el-button>
<el-button type="primary" @click="dialogVisible = false">确定</el-button>
</span>
```
这样,当点击取消按钮时,el-dialog会关闭。
#### 引用[.reference_title]
- *1* [element ui中el-dialog如何自定义标题,加图标](https://blog.csdn.net/qq_42931285/article/details/124701902)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Element ui关闭el-dialog时清除数据](https://blog.csdn.net/Temptat14x/article/details/130131410)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Element UI中el-dialog中内容超出自定义滚动条](https://blog.csdn.net/weixin_58206564/article/details/123467131)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文