Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支付宝小程序没有nextTick taro那该在何种类时机去出发获取元素? #13452

Closed
hyccpq opened this issue Mar 15, 2023 · 3 comments
Labels
F-vue3 Framework - Vue 3 T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x

Comments

@hyccpq
Copy link

hyccpq commented Mar 15, 2023

相关平台

支付宝小程序

小程序基础库: 2.16.1
使用框架: Vue 3

复现步骤

按照文档实例,在支付宝小程序中并不能获取到相关元素,是不是因为支付宝小程序没有nextTick的原因

export default {
    mounted() {
      Taro.nextTick(() => {
        // 使用 Taro.nextTick 模拟 setData 已结束,节点已完成渲染
        Taro.createSelectorQuery()
          .select('#only')
          .boundingClientRect()
          .exec((res) => console.log('res: ', res))
      })
    },
  }

期望结果

期望的结果是一种方式可以在动态渲染完成后能拿到节点信息进行计算操作处理。

实际结果

获取不到节点元素

环境信息

Taro CLI 3.6.1 environment info:
    System:
      OS: macOS 13.2.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 18.12.0 - /usr/local/bin/node
      Yarn: 1.22.18 - /usr/local/bin/yarn
      npm: 9.1.2 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.7 => 3.5.7
      @tarojs/components: 3.5.7 => 3.5.7
      @tarojs/plugin-framework-vue3: 3.5.7 => 3.5.7
      @tarojs/plugin-html: 3.5.7 => 3.5.7
      @tarojs/plugin-platform-weapp: 3.5.7 => 3.5.7
      @tarojs/runtime: 3.5.7 => 3.5.7
      @tarojs/taro: 3.5.7 => 3.5.7
      @tarojs/webpack5-runner: 3.5.7 => 3.5.7
      babel-preset-taro: 3.5.7 => 3.5.7
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x labels Mar 15, 2023
@TheKonka
Copy link
Member

https://github.com/NervJS/taro/blob/next/packages/taro-runtime/src/next-tick.ts

Taro.nextTick调用的是自己实现的,支付宝环境也能用

@TheKonka
Copy link
Member

image

按照文档实例,在支付宝小程序中并不能获取到相关元素

可以试下 waitUntil 🙃

@hyccpq
Copy link
Author

hyccpq commented Mar 16, 2023

这个方案太离谱了 可行确实也可行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants