1.1.1 • Published 3 years ago

vue-click-outside-extrame v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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>

Example for use argument

<template>
  <div>
    <div v-click-outside:[count]="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
      count: 0
    }
  },

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

    },

    hide (el,arg) {
      this.opened = false
      this.arg ++;
    }
  },

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

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

Badges

npm.io npm.io


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon