需要观察的行为目标元素
执行回调的函数
Optional
options: UseResizeObserverOptions配置项
<script setup lang="ts">
import { useResizeObserver } from "@eqian/utils-vue";
import {Ref, ref} from "vue";
const div1 = ref<HTMLElement>()
const {stop, start} = useResizeObserver(div1 as Ref<HTMLElement>, ({entries})=> {
console.log('尺寸变化', entries)
})
</script>
<template>
<div>
<div style="min-height: 100px;min-width: 100px" contenteditable ref="div1" />
<button @click="()=>start()">开始</button>
<button @click="()=>stop()">关闭</button>
</div>
</template>
观察一个或多个元素的尺寸变化,并在变化时执行指定的回调函数。