From c155ae6c8e01c00d4635eea2606fc394bc6bfeaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8C=89=E6=97=B6=E5=90=83=E9=A5=AD?= <1151770629@qq.com> Date: Thu, 2 Dec 2021 20:49:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=85=83=E7=B4=A0=E7=9A=84=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E9=9C=80=E8=A6=81=E5=9C=A8onMounted=E9=87=8C=E9=9D=A2?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vant/docs/markdown/use-rect.zh-CN.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/vant/docs/markdown/use-rect.zh-CN.md b/packages/vant/docs/markdown/use-rect.zh-CN.md index 23f726edb..31e8d4329 100644 --- a/packages/vant/docs/markdown/use-rect.zh-CN.md +++ b/packages/vant/docs/markdown/use-rect.zh-CN.md @@ -13,15 +13,18 @@ ``` ```js -import { ref } from 'vue'; +import { ref,onMounted } from 'vue'; import { useRect } from '@vant/use'; export default { setup() { const root = ref(); - const rect = useRect(root); - console.log(rect); // -> 元素的大小及其相对于视口的位置 + onMounted(()=>{ + const rect = useRect(root); + console.log(rect); // -> 元素的大小及其相对于视口的位置 + }) + return { root }; },