2020-09-28 20:19:10 +08:00
|
|
|
<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);
|
2020-10-30 00:56:11 +08:00
|
|
|
|
2020-09-28 20:19:10 +08:00
|
|
|
useClickOutside(wrapRef as Ref<HTMLDivElement>, () => {
|
|
|
|
emit('clickOutside');
|
|
|
|
});
|
2020-10-30 00:56:11 +08:00
|
|
|
|
2020-09-28 20:19:10 +08:00
|
|
|
return { wrapRef };
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|