scroll-view先hidden再出现,scroll-into-view无效
scroll-view如果先hidden再出现,scroll-into-view无效
<scroll-view scroll-y style= "height: 200px;" scroll-into-view= "yellow" hidden> <view id= "green" class= "scroll-view-item bc_green" ></view> <view id= "red" class= "scroll-view-item bc_red" ></view> <view id= "yellow" class= "scroll-view-item bc_yellow" ></view> <view id= "blue" class= "scroll-view-item bc_blue" ></view> </scroll-view> |
先hidden,然后通过setData把hidden去掉,此时scroll-into-view无效
3 回复
刚刚测试了,有效。
< view wx:if = '{{show}}' > < scroll-view scroll-y style = "height: 200px;" scroll-into-view = "{{intoView}}" > < view wx:for = '{{list}}' wx:key = 'id{{index}}' id = "{{item}}" class = "scroll-view-item bc_{{item}}" ></ view > </ scroll-view > </ view > < view class = "btn-area" > < button size = "mini" bindtap = "tap" >点击让scroll-view出现</ button > </ view > |
Page({ data: { show: false , intoView: null , list: [ 'green' , 'red' , 'yellow' , 'blue' ] }, onLoad: function () { }, tap: function (e) { this .setData({ show: true , intoView: 'yellow' }) }, }) |
.scroll-view-item { width : 100% ; height : 100px ; } .bc_green { background : green ; } .bc_red { background : red ; } .bc_yellow { background : yellow; } .bc_blue { background : blue ; } |