scroll-into-view使用
第一种,不够灵活
<scroll-view scroll-y="true" style="height: 400rpx;"
:scroll-into-view="bottomId" scroll-with-animation="true">
<view v-for="(item,index) in list">
<view :style=" 'height: 180rpx; background-color:' + item.color"></view>
</view>
<view :id="'dade'+(list.length)">底部</view>
</scroll-view>
setTimeout(()=>{
this.num = this.list.length
this.bottomId = 'dade'+ (this.num)
},500)
第二,完美
<scroll-view scroll-y="true" style="height: 400rpx;"
:scroll-into-view="bottomId" scroll-with-animation="true">
<view v-for="(item,index) in list">
<view :id="'dade'+(index)" :style=" 'height: 180rpx; background-color:' + item.color"></view>
</view>
</scroll-view>
pageToBottom(){
let num = this.datas.length-1;
this.bottomIds = 'p'+ (num)
}