仿美团scroll-into-view 定位

<scroll-view scroll-x style="width:100%;white-space:nowrap">
<view wx:for="{
   
   {30}}" style="display:inline-block; margin:10rpx;border:1rpx solid red" data-id="{
   
   {index}}" bindtap="scroll">{
   
   {index}}</view>
</scroll-view>
<scroll-view scroll-y style='height:400rpx;' scroll-into-view="{
   
   {intoView}}" scroll-with-animation>
<view wx:for="{
   
   {30}}" id="view{
   
   {index}}" style="height:100rpx;margin:10rpx;border:1rpx solid blue">{
   
   {index}}</view>
</scroll-view>
const app = getApp()

Page({
data: {

},
scroll: function(e){
this.setData({
intoView: "view"+e.currentTarget.dataset.id
})
}
})

转载 https://www.cnblogs.com/xiaobai-y/p/10020898.html

猜你喜欢

转载自blog.csdn.net/qq_38932474/article/details/94463417