ant-design-vue/components/popconfirm/demo/dynamic-trigger.vue

63 lines
1.2 KiB
Vue
Raw Normal View History

2018-01-15 09:33:34 +00:00
<template>
<div>
<md>
## 条件触发
可以判断是否需要弹出
</md>
<Popconfirm
title="Are you sure delete this task?"
:visible="visible"
@visibleChange="handleVisibleChange"
@confirm="confirm"
@cancel="cancel"
okText="Yes"
cancelText="No"
>
<a href="#">Delete a task</a>
</Popconfirm>
<br />
<br />
2018-01-23 10:55:39 +00:00
Whether directly execute<a-checkbox defaultChecked @change="changeCondition" />
2018-01-15 09:33:34 +00:00
</div>
</template>
<script>
import { Popconfirm, Checkbox } from 'antd'
export default {
data () {
return {
visible: false,
condition: true,
}
},
methods: {
changeCondition (e) {
this.condition = e.target.checked
},
confirm () {
this.visible = false
},
cancel () {
this.visible = false
},
handleVisibleChange (visible) {
if (!visible) {
this.visible = false
return
}
// Determining condition before show the popconfirm.
console.log(this.condition)
if (this.condition) {
this.confirm() // next step
} else {
this.visible = true
}
},
},
components: {
Popconfirm,
Checkbox,
},
}
</script>