UNPKG

bootstrap-vue

Version:

Quickly integrate Bootstrap 4 components with Vue.js

22 lines (21 loc) 565 B
export default { mounted: function mounted() { if (typeof document !== 'undefined') { document.documentElement.addEventListener('click', this._clickOutListener); } }, beforeDestroy: function beforeDestroy() { if (typeof document !== 'undefined') { document.removeEventListener('click', this._clickOutListener); } }, methods: { _clickOutListener: function _clickOutListener(e) { if (!this.$el.contains(e.target)) { if (this.clickOutListener) { this.clickOutListener(); } } } } };