From ed156f24c57185f088025299b397b6f62d63c7ff 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: Fri, 3 Dec 2021 09:46:59 +0800 Subject: [PATCH] docs(@vant/use): useRect should be used inside onMounted (#9989) --- packages/vant/docs/markdown/use-rect.zh-CN.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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..41842757c 100644 --- a/packages/vant/docs/markdown/use-rect.zh-CN.md +++ b/packages/vant/docs/markdown/use-rect.zh-CN.md @@ -13,16 +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 }; }, };