vue-click-off
A custom Vue directive that can be used to detect when you've clicked off of an element. Directive also accepts ignored elements, which when clicked, will not fire the directive callback (e.g. a dropdown menu)
Requirements
vue: ^2.6.0
Installation
$ npm install vue-click-off --save
Usage
- Import the directive into your component
;name: 'VueClickOff'directives:clickOffmethods:{;}
- Use the directive in your template
Alert when you click off of me!
Options
You have the option to ignore specified pieces of the DOM from firing your click off handler. For example, if you wanted to click a menu item in a dropdown.
- Import the directive into your component
- Specify an array of class names as a data property
- Use the directive in your template, passing the array of ignored class names
;name: 'VueClickOff'directives:clickOff{return'ignoredEl': 'dontFire'}methods:{;}
Alert when you click off of me!Ignored :(