Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

a hook function triggered when clicking outside the component, used like lifecycle hooks

License

Notifications You must be signed in to change notification settings

liuycy/vue-click-outside-hook

Repository files navigation

vue-click-outside-hook

A hook function triggered when clicking outside the component, used like lifecycle hooks.

Install

use yarn

yarn add vue-click-outside-hook

or use npm

npm install vue-click-outside-hook

Usage

for Vue 3.x use onClickOutside in setup()

<script>
import { defineComponent } from 'vue'
import onClickOutside from 'vue-click-outside-hook';

export default defineComponent({
  setup() {
    onClickOutside(e => {
      // after clicking outside the component
      // this callback will be triggered
    })
  }
})
</script>

About

a hook function triggered when clicking outside the component, used like lifecycle hooks

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published