/*! For license information please see 9160.b9db01ad.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["9160"],{17786:function(n,t,s){"use strict";s.r(t);var e=s("80681");let a=["innerHTML"];t.default={setup:()=>({html:""}),render:()=>((0,e.wg)(),(0,e.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

useRect

\n

Intro

\n

Get the size of an element and its position relative to the viewport, equivalent to Element.getBoundingClientRect.

\n

Usage

\n

Basic Usage

\n
<div ref="root" />\n
\n
import { ref, onMounted } from 'vue';\nimport { useRect } from '@vant/use';\n\nexport default {\n  setup() {\n    const root = ref();\n\n    onMounted(() => {\n      const rect = useRect(root);\n      console.log(rect); // -> the size of an element and its position relative to the viewport\n    });\n\n    return { root };\n  },\n};\n
\n

API

\n

Type Declarations

\n
function useRect(\n  element: Element | Window | Ref<Element | Window | undefined>,\n): DOMRect;\n
\n

Return Value

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescriptionType
widthWidth of the elementnumber
heightHeight of the elementnumber
topThe distance from the top to the top-left of the viewportnumber
leftThe distance from the left to the top-left of the viewportnumber
rightThe distance from the right to the top-left of the viewportnumber
bottomThe distance from the bottom to the top-left of the viewportnumber
\n
'},null,8,a))}}}]);