当我在我的模态之外单击时如何关闭我的模态?

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

我正在尝试使用此库 https://www.npmjs.com/package/click-outside-vue3 在我单击模式外部时关闭?

我做了这个代码:

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

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

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

但它不起作用,我想关闭模态

我还设置了 main.js

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

您是否设置了文档中的指令?

directives: {
      clickOutside: vClickOutside.directive
    },

```