Skip to content

Resize 元素尺寸监听

介绍

监听组件包裹的元素尺寸变化,获取实时的尺寸和位置,便于内容的展示计算。

基础用法

通过 @resize 监听元素尺寸的实时 widthheight 变化。

html
<vd-resize @resize="handleResize">
  内容内容内容
</vd-resize>
ts
import type { NodeRect } from '@vital-design/shared';

function handleResize(info: NodeRect) {
  console.log('尺寸变化:', info);
};

API

Props

参数说明类型默认值
debounce计算防抖时间string | number0
fixed是否固定状态(撑满父元素)booleanfalse

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击时触发MouseEvent
resize元素尺寸变化时触发NodeRect

Slots

名称说明
default自定义内容

赣ICP备2025061025号-1