vue3-clickoutside-component
v2.0.0
Published
A simple Vue3 directive for clicking outside component
Downloads
49
Maintainers
Readme
Vue3-clickoutside-component
A simple Vue3 directive for clicking outside component.
Install
npm install --save vue3-clickoutside-component
How to use it ?
import { createApp } from 'vue'
import App from './App.vue'
import clickOutside from 'vue3-clickoutside-component'
const app = createApp(App)
app.use(clickOutside)
<template>
<div class="dropdown" v-click-outside="() => hideDropdown()">
</template>
<script setup>
function hideDropdown() {
console.log("close dropdown")
}
</script>
### OR
<script>
methods: {
hideDropdown() {
console.log("close dropdown")
}
}
</script>