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

嵌套生成多级的模板,超过阈值时,会使用comp生成自定义组件,导致Taro.createSelectorQuery().select获取不到comp里面的组件 #9066

Closed
ywmail opened this issue Apr 8, 2021 · 3 comments
Labels
F-vue2 Framework - Vue 2 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@ywmail
Copy link
Contributor

ywmail commented Apr 8, 2021

相关平台

微信小程序

小程序基础库: 2.16.0
使用框架: Vue 2

复现步骤

  1. 嵌套多级view,超过阈值,生成comp组件嵌套(小程序开发工具中看不到shadow-root,在PC版小程序调试时可以看到)
  2. 在组件内使用Taro.createSelectorQuery().select('#my-comp'),无法获取到组件信息
  3. 修改嵌套层级后,可以获取到。

期望结果

Taro.createSelectorQuery().select('#my-comp').boundingClientRect()可以获取到组件

实际结果

无法获取到组件。显示null。

环境信息

👽 Taro v3.2.0


  Taro CLI 3.2.0 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.15.4 - D:\tools\nodejs\node.EXE
      Yarn: 1.22.10 - D:\tools\nodejs\yarn.CMD
      npm: 6.14.10 - D:\tools\nodejs\npm.CMD

补充信息

相关代码:
https://github.com/NervJS/taro/blob/next/packages/shared/src/template.ts#L1:L10

  1. 此处文档说明有问题,在超过模板嵌套阈值后,会生成自定义组件
    https://taro-docs.jd.com/taro/docs/migration/#scope-%E5%92%8C-componenttype
  2. 当前没有API能够获取到自定义组件实例(作用域)
@taro-bot2 taro-bot2 bot added F-vue2 Framework - Vue 2 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Apr 8, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 9, 2021

看看微信小程序的文档吧,穿透自定义组件获取的写法:'>>>'

@qwerlp
Copy link

qwerlp commented Jun 24, 2021

看看微信小程序的文档吧,穿透自定义组件获取的写法:'>>>'

Taro.createSelectorQuery().in(this),自定组件里面这个this(实例)怎么拿到

@Chen-jj
Copy link
Contributor

Chen-jj commented Jun 24, 2021

@qwerlp 看看这个:#9357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue2 Framework - Vue 2 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

3 participants