vue-clickaway
vue-clickaway copied to clipboard
There is any way to use it globally..?
Where have a dropdown or something like that we need this, my question is can we use this globally.? that's why we don't need to import
this in every component.
I'm also interested in this.
In main.js, simply do
Vue.mixin({
mixins: [ clickaway ]
})
Anything you define inside Vue.mixin, is globally available, that be data, methods, computed or more mixins.
Using in component template should be defined in directives:
Vue.component('iam-select', {
directives: {
onClickaway: VueClickaway.directive,
},
and html-file should have
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-clickaway.min.js"></script>