signup
signup

Reputation: 165

How can i close my modal when i click outside of my modal?

I am trying to use this library https://www.npmjs.com/package/click-outside-vue3 for close when i will click outside of the modal?

i made this code:

<div
    v-if="dialogFoundation"
    v-click-outside="close"
  >

 import vClickOutside from 'click-outside-vue3'
 directives: {
  clickOutside: vClickOutside.directive
},
setup() {

  const close = () => {
        console.log(4343)
  }
}

but its not working, i want to close the modal

also i setup the main.js

import vClickOutside from "click-outside-vue3"
...
createApp(App)
  .use(vClickOutside)

Upvotes: 0

Views: 256

Answers (1)

Wax
Wax

Reputation: 110

have you set the directive as it's found in the documentation ?

directives: {
      clickOutside: vClickOutside.directive
    },

```

Upvotes: 1

Related Questions