From ab55e04694bff7997e28da1259151cf7cc687e53 Mon Sep 17 00:00:00 2001 From: Ymm0008 Date: Wed, 9 Nov 2022 15:46:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20taro=20h5=E5=92=8C?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/lottoroll/index.taro.vue | 31 +++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/packages/__VUE/lottoroll/index.taro.vue b/src/packages/__VUE/lottoroll/index.taro.vue index e551caf..a2147e5 100644 --- a/src/packages/__VUE/lottoroll/index.taro.vue +++ b/src/packages/__VUE/lottoroll/index.taro.vue @@ -102,19 +102,32 @@ export default create({ const lottoRollWrap = ref(); const lottoWrap = ref(); + + const getLottoRollDom = () => { + const query = Taro.createSelectorQuery(); + query.selectAll(".lotto-roll-wrap").boundingClientRect(); + query.selectAll(".lotto-wrap").boundingClientRect(); + query.exec((res) => { + lottoRollWrap.value = res[0]; + lottoWrap.value = res[1]; + }); + }; onMounted(() => { - eventCenter.once((getCurrentInstanceTaro() as any).router.onReady, () => { - const query = Taro.createSelectorQuery(); - query.selectAll(".lotto-roll-wrap").boundingClientRect(); - query.selectAll(".lotto-wrap").boundingClientRect(); - query.exec((res) => { - lottoRollWrap.value = res[0]; - lottoWrap.value = res[1]; + if (Taro.getEnv() == "WEAPP") { + eventCenter.once( + (getCurrentInstanceTaro() as any).router.onReady, + () => { + getLottoRollDom(); + } + ); + } else { + Taro.nextTick(() => { + getLottoRollDom(); }); - }); + } }); - const distanceObj = ref>([]); + const distanceObj: any = ref([]); const animateRun = (timestamp: number) => { // const timestamp = 0;