Blame view

src/components/ClickOutSide/index.vue 532 Bytes
陈文彬 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<template>
  <div ref="wrapRef"><slot /></div>
</template>
<script lang="ts">
  import type { Ref } from 'vue';
  import { defineComponent, ref } from 'vue';

  import { useClickOutside } from '/@/hooks/web/useClickOutside';

  export default defineComponent({
    name: 'ClickOutSide',

    setup(_, { emit }) {
      const wrapRef = ref<Nullable<HTMLDivElement | null>>(null);
15
陈文彬 authored
16
17
18
      useClickOutside(wrapRef as Ref<HTMLDivElement>, () => {
        emit('clickOutside');
      });
19
陈文彬 authored
20
21
22
23
      return { wrapRef };
    },
  });
</script>