From 3fdeeb7d12cb7d99bbc92aa0b1d8666173c90852 Mon Sep 17 00:00:00 2001 From: chenruilong Date: Wed, 20 Sep 2023 14:44:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20$nextTick=20=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nextTick-function/nextTick-function.uvue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pages/component-instance/nextTick-function/nextTick-function.uvue b/pages/component-instance/nextTick-function/nextTick-function.uvue index cf513cb..91f8c96 100644 --- a/pages/component-instance/nextTick-function/nextTick-function.uvue +++ b/pages/component-instance/nextTick-function/nextTick-function.uvue @@ -53,11 +53,13 @@ export default { }, methods: { nextTickCallback (): void { - this.width = 200 + this.width = 100 uni.createSelectorQuery().select('.rect').boundingClientRect(null).exec((ret: Array) => { const rect = ret[0] as NodeInfo - + + this.width = 200 + this.$nextTick(() => { uni.createSelectorQuery().select('.rect').boundingClientRect(null).exec((ret: Array) => { const newRect = ret[0] as NodeInfo @@ -69,11 +71,13 @@ export default { }); }, nextTickPromise (): void { - this.height = 200 + this.height = 100 uni.createSelectorQuery().select('.rect').boundingClientRect(null).exec((ret: Array) => { const rect = ret[0] as NodeInfo + this.height = 200 + this.$nextTick().then(() => { uni.createSelectorQuery().select('.rect').boundingClientRect(null).exec((ret: Array) => { const newRect = ret[0] as NodeInfo -- GitLab