mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-09 21:22:26 +03:00
20 lines
492 B
JavaScript
20 lines
492 B
JavaScript
|
|
export default {
|
|
bind (el, binding, vnode) {
|
|
el['@clickoutside'] = e => {
|
|
if (
|
|
!el.contains(e.target) &&
|
|
!(vnode.context.popupElm && vnode.context.popupElm.contains(e.target)) &&
|
|
binding.expression &&
|
|
vnode.context[binding.expression]
|
|
) {
|
|
binding.value()
|
|
}
|
|
}
|
|
document.addEventListener('click', el['@clickoutside'], false)
|
|
},
|
|
unbind (el) {
|
|
document.removeEventListener('click', el['@clickoutside'], false)
|
|
}
|
|
}
|