钉钉E应用写回到顶部和滚动后元素固定定位在可视区域顶部

index.axml

<view class="{{class}}" hidden="{{isShow}}"> <input class="examSearch" onInput="examSearch" onSubmit="examSearch" type="text" placeholder="考试搜索"/> </view>

index.js

Page({ data:{ class:'', }, // 滚动定位 onPageScroll({ scrollTop }) { this.setData({ scrollTop: scrollTop }); if (scrollTop >= 45){ this.setData({ class:"fixed" }) } else { this.setData({ class:"" }) } }, })

index.acss

.fixed{ position: fixed; top: 0; left: 0; right: 0; z-index: 999; background-color: white; border-bottom: 2rpx solid #ddd; }

猜你喜欢

转载自blog.csdn.net/qq_43119205/article/details/84072241