Vue 3 directive to detect clickaway events
pnpm add @manusanchev/vue3-clickaway
yarn install @manusanchev/vue3-clickaway
npm install @manusanchev/vue3-clickaway
import { createApp } from "vue";
import ClickAway from "@manusanchev/vue3-clickaway";
import App from "./App.vue";
const app = createApp(App);
app.use(ClickAway);
app.mount("#app");
plugins/clickaway.client.ts
import ClickAway from "@manusanchev/vue3-clickaway";
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(ClickAway);
});
<script setup lang="ts">
function onClickAway() {
// your code here
}
</script>
<template>
<div v-clickaway="onClickAway">
<!-- Content -->
</div>
</template>