Giter Site home page Giter Site logo

Comments (16)

Chaunjie avatar Chaunjie commented on August 24, 2024

你的res出来的是什么

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

我试着打印了一下res res是null 一开始有怀疑是.folder-content__ + this.componentId的拼接问题导致取不到这个节点 但是后来打印.folder-content__ + this.componentId 是正确的值 ..所以..陷入了迷茫
想问一下 在你那边会有取不到这个值的情况吗..
我用的是wepy版本..不过我是直接拷贝src/components的folder的 这个应该就没有影响吧...

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

没有影响,你这样写试试wx.createSelectorQuery().in(this)...

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

是将原代码更改为:

      wx.createSelectorQuery().in(this).select('.folder-content__' + this.componentId).boundingClientRect((res) => {
        this.height = res.height
        this.$apply()
      }).exec()


控制台提示An SelectorQuery call is ignored because no proper page or component is found. Please considering using SelectorQuery.in to specify a proper one.

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

我先尝试跑一下clone的demo看看会不会有这个问题~

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

你是不是在未渲染就去获取了?,你尝试下做个延迟能不能取到,如果延迟能取到的话说明你未渲染的时候就去获取dom

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

这句话是在folder组件的wepy文件里的.. 原先就有的..我是直接另一个页面引入folder这个组件 访问这个页面的时候报的这个错误....
不过我刚才编译了下clone的这个 没有这个问题。。。
我把我页面其他代码屏蔽掉。。也没这个问题了。。然后试了一下。。破案了
我的代码是

<block wx:if="{{!abnor.loading}}">
      ....
    </block>
    <block wx:else>
      <folder title="会员信息" componentId="1">
        <view slot="content">
          ...
        </view>
      </folder>
    </block>

如果我的block里是wx:if="{{!abnor.loading}}"的话 就会有这个问题 如果我写的是wx:if="{{!true}}" 都不会有问题... 不明白为什么 =。=

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

wx:if判断语句导致未渲染

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

啊我明白了..因为组件还未渲染但是先执行了组件内的onLoad?那...如果我有这个wx:if的需求的话...有没有什么好的解决方式呢

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

你可以尝试等!abnor.loading这个条件成立之后再去获取dom

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

但是这句话是写在folder组件内的onLoad里的呀..... 感觉直接改组件传入参数告知是否Loading然后好像..不是特别好?

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

明白问题缘由啦 这个需求我自己解决 谢谢你啦!

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

针对你这个问题,给组件传唯一的解决方案,因为组件并不知道啥时候真正渲染了,只能等传过去的值改变了才能知道

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

哈哈是的 所以我想了想..只能对原组件开刀了........

from kai-ui.

Chaunjie avatar Chaunjie commented on August 24, 2024

对的,因为你这个需求在组件设计的时候是不会考虑这一块,所以只能这么干,还有一种方式就是在原组件外围包一层组件,在中间组件监控数据变化,这种可以避免对原组件的修改,也可以做扩展

from kai-ui.

xyohn avatar xyohn commented on August 24, 2024

好的明白 谢谢

from kai-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.