Giter Site home page Giter Site logo

Comments (1)

lypigg avatar lypigg commented on July 23, 2024

目前我的处理方法。在vtabs-content的index.wxml 中增加了一个 标记

  <view class="weui-vtabs-content__item" style="position: relative;" id="weui-vtabs-content__{{tabIndex}}">
  <slot></slot>
  <view class="flag" style="position: absolute;top: {{flagTop}}px;width: 1px;height: 1px;right: 0;opacity: 0;">
  </view>
</view>

修改了vtabs-content的index.js文件,在attached生命周期中增加边界碰撞监听,进行内容高度的变化监听。从而再更新vtabs中的heightRecords

attached: function attached() {
                             this._observer = wx.createIntersectionObserver(this)
.                          relativeTo('.weui-vtabs-content__item').observe('.flag',res => {
                                 this.calcHeight(this.change)
                             })
                         },          

                         detached: function () {
                             this._observer.disconnect()
                         }
                     },
                     methods: {
                         calcHeight: function calcHeight(callback) {
                             this.change = callback
                             var query = this.createSelectorQuery();
                             query.select('.weui-vtabs-content__item').boundingClientRect((rect) => {
                                 this._rect = rect
                                 this.setData({
                                     flagTop: rect.height
                                 })
                                 callback && callback(rect);
                             }).exec();
                         }
                     }
                 });

from miniprogram-component-plus.

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.