代码:
wxml: <view class="segment-group"> <scroll-view enable-flex class="segment-header {{scrollTop > 200?'scrollTop':''}}"> <block wx:for="{{items}}" wx:key="item"> <view class="segment-item active" wx:if="{{currentIndex === index}}" bindtap="onItemTapEvent" data-index="{{index}}">{{item}}</view> <view class="segment-item" wx:else bindtap="onItemTapEvent" data-index="{{index}}">{{item}}</view> </block> </scroll-view> <block wx:for="{{items}}" wx:key="item"> <slot name="{{index}}" wx:if="{{currentIndex === index}}"></slot> </block> </view> wxss: .scrollTop{ position:fixed; display:flex; justify-content:space-evenly; top:0; left:0; right:0; border-radius:none; } js: onPageScroll:function(event){ console.log(event); var scrollTop=event.scrollTop; this.setData({ scrollTop:scrollTop, }) },
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。