scroll-into-view 简单demo


index.wxml
 
 
<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>
 
 
 
index.js
 
 
 
 
 
const app = getApp()

Page({
data: {

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM