iview弹窗打开的回调函数
时间: 2023-10-27 16:17:20 浏览: 155
在 iView 中,弹窗组件 `Modal` 提供了 `on-ok` 和 `on-cancel` 两个事件回调函数,分别在点击确认和取消按钮时触发。
如果需要在弹窗打开时执行回调函数,可以使用 `before-open` 事件,该事件在弹窗打开前触发,可以在回调函数中执行需要的操作。
以下是一个示例代码:
```html
<template>
<div>
<Button type="primary" @click="handleOpenModal">打开弹窗</Button>
<Modal
v-model="visible"
title="提示"
:before-open="handleBeforeOpen"
@on-ok="handleOk"
@on-cancel="handleCancel"
>
<p>这是一个弹窗内容</p>
</Modal>
</div>
</template>
<script>
export default {
data() {
return {
visible: false
}
},
methods: {
handleOpenModal() {
this.visible = true
},
handleBeforeOpen() {
console.log('弹窗即将打开')
},
handleOk() {
console.log('点击了确认按钮')
},
handleCancel() {
console.log('点击了取消按钮')
}
}
}
</script>
```
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)