Trigger function when clicking outside a component for Vue.js
Vue 2.0 compatible, see demo: https://egoistian.com/onclick-outside
$ npm install --save onclick-outside
<template>
<click-outside :handler="handleClickOutside">
<button>don't click me, click outside!</button>
</click-outside>
</template>
<script>
import ClickOutside from 'onclick-outside'
export default {
methods: {
handleClickOutside(e) {
console.log('hey, why did you touch outside?')
}
},
components: {
ClickOutside
}
}
</script>
See https://github.com/kentor/react-click-outside#not-working-on-ios
MIT © EGOIST