You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/popconfirm/demo/dynamic-trigger.md

69 lines
1.3 KiB

<cn>
#### 条件触发
7 years ago
可以判断是否需要弹出。
</cn>
7 years ago
<us>
#### Conditional trigger
Make it pop up under some conditions.
</us>
```html
<template>
<div>
<a-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>
</a-popconfirm>
<br />
<br />
Whether directly execute<a-checkbox defaultChecked @change="changeCondition" />
</div>
</template>
7 years ago
<script>
import { message } from 'ant-design-vue'
7 years ago
export default {
data () {
return {
visible: false,
condition: true,
}
},
methods: {
changeCondition (e) {
this.condition = e.target.checked
},
confirm () {
this.visible = false
message.success('Next step.')
7 years ago
},
cancel () {
this.visible = false
message.error('Click on cancel.')
7 years ago
},
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
}
},
},
}
</script>
```