vue-click-outside

ClickOutside directive for Vue
2,456,320 302
Install
npm install vue-click-outside
Latest Version:1.1.0
License:MIT
Last Updated:Aug 13, 2021
Links: GitHub  ·  npm
Maintainer: fundon

ClickOutside

Vue click outside directive.

Installation

$ npm install vue-click-outside

Example

<template>
  <div>
    <div v-click-outside="hide" @click="toggle">Toggle</div>
    <div v-show="opened">Popup item</div>
  </div>
</template>

<script>
import ClickOutside from 'vue-click-outside'

export default {
  data () {
    return {
      opened: false
    }
  },

  methods: {
    toggle () {
      this.opened = true
    },

    hide () {
      this.opened = false
    }
  },

  mounted () {
    // prevent click outside event with popupItem.
    this.popupItem = this.$el
  },

  // do not forget this section
  directives: {
    ClickOutside
  }
}
</script>

Badges


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

Version History

Version Released License
1.1.0 MIT
1.0.7 MIT
1.0.6 MIT
1.0.5 MIT
1.0.4 MIT