收藏
回答

自定义组件中获取节点报错?

/tr.js
... 
lifetimes:{
        ready:()=>{
            const query = wx.createSelectorQuery().in(this)
            query.select('.tr').boundingClientRect(function(res){
                console.log('>>>>',res)
            }).exec()
            console.log('lifetimes attached!')
        }
    },

/tr.wxml
<!--components/table/tr.wxml-->
<scroll-view scroll-x="{{options.scrollX}}" scroll-y="{{options.scrollY}}">
    <view class="tr">
        <slot></slot>
    </view>
</scroll-view>


在页面中遍历了tr组件。但是会报错:

请问这个错误该如何处理?我已经找过相关提问和信息,但没有有效信息。



回答关注问题邀请回答
收藏

1 个回答

  • 微盟
    微盟
    2023-05-15

    有没有可能是渲染时序的问题,在js尝试读取自定义组件时,该组件没有完全渲染完成。

    2023-05-15
    有用
    回复
登录 后发表内容