A
A
Alexander2020-04-20 12:10:13
Vue.js
Alexander, 2020-04-20 12:10:13

How to close an element when clicked outside its scope in VUEJS?

Hello, I made this modal window:

<template>
<div>
<div :class="{ 'is-active': isNextTab }">
<!-- Content -->
</div>
<button.v-on:click="nextTap()">SEND</button>
</div>
</template>
<script>
export default {
  data () {
    return {
      isNextTab: false
    }
  },
  methods: {
    nextTap: function () {
      if (this.isNextTab === false) {
        this.isNextTab = true
      } else {
        this.isNextTab = false
      }
    }
  }
}
</script>


But the problem is that if I click outside the area of ​​the modal window, then it will not close, but I would like it to close.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question