Skip to content

Resize

When the document flow size wrapped by the component changes, the resize event is triggered. Generally used to listen for size and position information changes caused by content updates, and then recalculate the layout based on this.

Component Types

Basic Usage

Do not add additional layout styles to wd-resize itself, but place the content to be monitored in the default slot.

html
<wd-resize @resize="handleResize">
  <view :style="{ background: '#4d80f0', width, height }"></view>
</wd-resize>
ts
import { onReady } from '@dcloudio/uni-app'
import { ref } from 'vue'

const width = ref('')
const height = ref('')

onReady(() => {
  setTimeout(() => {
    width.value = '100px'
    height.value = '100px'
  }, 1500)
})

function handleResize(detail: Record<string, string | number>) {
  const { height, width, top, right, bottom, left } = detail
}

Resize Attributes

ParameterDescriptionTypeDefault Value
custom-styleCustom root node stylestring''
custom-classCustom root node style classstring''
custom-container-classCustom container style classstring''

Resize Events

Event NameDescriptionParameters
resizeTriggered when size changes{ width: number; height: number; top: number; right: number; bottom: number; left: number }

Resize Slots

NameDescription
defaultContent that needs to listen for size changes

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-resize-container-min-size$n-1组件级 CSS 变量定义
--wot-resize-wrapper-z-index-9999容器最小宽高

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.