Skip to content

Offset 偏移量尺寸计算

介绍

获取实时的多个尺寸渲染时的实际尺寸大小,便于组件响应式偏移量的计算。

基础用法

通过 size 设置单/多个尺寸,@resize 监听元素尺寸的实时变化。

html
<vd-offset :size="sizes" @resize="handleResize" />
ts
const sizes = ['10px', '5px', '8rpx', 10, '2em'];

function handleResize(size: number) {
  console.log('尺寸计算变化:', size);
};

TIP

size 支持所有 css 尺寸,设置 number 类型的尺寸时,会乘于 css 内预置的 1px 尺寸以支持响应式。

API

Props

参数说明类型默认值
size偏移大小,支持多个string | number | (string | number)[]0

代替原始 Props

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

Events

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

赣ICP备2025061025号-1