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

父容器使用wx:if或者hidden,sticky粘性布局就会失效,文档里面没有写,这是正常情况还是bug? #5470

Closed
cao1987 opened this issue Jul 4, 2023 · 8 comments

Comments

@cao1987
Copy link

cao1987 commented Jul 4, 2023

重现链接

<view style="height: 10000px;"> <view style="background-color: aqua;height: 100px;"></view> <view wx:if="{{show}}"> <van-sticky> <button>按钮</button> </van-sticky> </view> </view>

Vant Weapp 版本

1.10.20

描述一下你遇到的问题。

Sticky粘性布局会失效

重现步骤

父容器使用wx:if判断的时候,Sticky直接失效,父容器使用hidden的时候,初始加载完成的时候元素直接就在最顶部,这种情况是设定如此吗?能不能解决

设备/浏览器

No response

@johnsonwong666
Copy link
Collaborator

父元素不渲染理论上子元素的也不会渲染的,sticky自然无效。

@cao1987
Copy link
Author

cao1987 commented Jul 4, 2023

是使用了wx:if,元素经过判断后渲染出来了

@johnsonwong666
Copy link
Collaborator

是使用了wx:if,元素经过判断后渲染出来了

wx:if={{false}} sticky 还出来了?

@cao1987
Copy link
Author

cao1987 commented Jul 4, 2023

是使用了wx:if,元素经过判断后渲染出来了

wx:if={{false}} sticky 还出来了?

不是啊,因为有两个盒子,每个盒子里面都有一个van-sticky 组件,我用wx:if控制不同条件下,只展示其中一个盒子,展示出来的里面的sticky 是失效的

@johnsonwong666
Copy link
Collaborator

johnsonwong666 commented Jul 4, 2023

@cao1987
Copy link
Author

cao1987 commented Jul 4, 2023

https://developers.weixin.qq.com/minigame/dev/devtools/minicode.html 来个代码片段看一下 @cao1987

https://developers.weixin.qq.com/s/iFje0smc7iJn
微信的代码片段默认不支持npm包,我这直接复制过去的看看能不能看得到

@johnsonwong666
Copy link
Collaborator

看了一下 除了hidden的时候有问题外 其他都是正常吸顶的

@johnsonwong666
Copy link
Collaborator

该issue 在vant-weapp2.0 解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants