拓展组件sticky生命周期不当导致节点高度计算错误
发布于 7 年前 作者 minjiang 5414 次浏览 来自 官方Issues

原组件内生命周期配置:

lifetimes: {

attached: function attached() {

this.data._attached = true;

if (!this.data.disabled) this.initObserver();

},

detached: function detached() {

this.data._attached = false;

this.disconnectObserver();

}

}

页面调用组件内的子元素高度为动态值时,组件内生命周期attached计算的元素高度是不正确的,只有子元素是固定值才计算准确。

调用方式如下:

<mp-sticky offset-top="0" bindscroll="bindScroll">

<view class="nav" style="height:{{btn.top + btn.height + 'px'}}">

测试内容

</view>

</mp-sticky>

尝试通过修改生命周期attached为ready,目前暂未发现问题。





1 回复

你好,请提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部