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/modal/confirm.js

46 lines
1.0 KiB

7 years ago
import Vue from 'vue'
import ConfirmDialog from './ConfirmDialog'
export default function confirm (config) {
const div = document.createElement('div')
const el = document.createElement('div')
div.appendChild(el)
7 years ago
document.body.appendChild(div)
7 years ago
let confirmDialogInstance = null
function close (...args) {
destroy(...args)
}
function destroy (...args) {
if (confirmDialogInstance && div.parentNode) {
confirmDialogInstance.$destroy()
confirmDialogInstance = null
div.parentNode.removeChild(div)
}
const triggerCancel = args && args.length &&
args.some(param => param && param.triggerCancel)
if (config.onCancel && triggerCancel) {
config.onCancel(...args)
}
}
function render (props) {
const confirmDialogProps = {
props,
}
7 years ago
return new Vue({
el: el,
7 years ago
render () {
return <ConfirmDialog {...confirmDialogProps} />
7 years ago
},
})
}
confirmDialogInstance = render({ ...config, visible: true, close })
return {
destroy: close,
}
}