小程序scroll-view 实现定位锚点 scroll-into-view属性设置要展示部分的id,scroll-with-animation="true"设置动画效果 ,scroll-view 容器要设置高度
<scroll-view scroll-into-view="{{toView}}" style="height:400px" scroll-y="true" scroll-with-animation="true">
<view>
<view class="table-list">
<view style="display:flex">
<view style="width:13px;height:13px;border-radius:50%;background:#3F8ADF;margin-right:10px;margin-top:9px"></view>
<view class="tableTitle" id="xsjl">我的销售录入记录</view>
</view>
<view style="overflow:scroll;">
<view class="tableTh">
<view class="th">单据日期</view>
<view class="th">订单编号</view>
<view class="th">BA姓名</view>
<view class="th">会员手机号</view>
<view class="th">会员姓名</view>
<view class="th">原价金额</view>
<view class="th">实收金额</view>
</view>
<view class="tableTh" wx:for="{{list}}" wx:key="index">
<view class="tr">{{item.riqi}}</view>
<view class="tr">{{item.num}}</view>
<view class="tr">{{item.baName}}</view>
<view class="tr">{{item.phone}}</view>
<view class="tr">{{item.name}}</view>
<view class="tr">{{item.price}}</view>
<view class="tr">{{item.reaPrice}}</view>
</view>
</view>
</view>
<view class="table-list">
<view class="tableTitle " id="hejl">
<view style="display:flex">
<view style="width:13px;height:13px;border-radius:50%;background:#3F8ADF;margin-right:10px;margin-top:7px"></view>
我的核销记录</view>
</view>
<view style="overflow:scroll;">
<view class="tableTh">
<view class="th">核销日期</view>
<view class="th">核销类型</view>
<view class="th">BA姓名</view>
<view class="th">会员手机号</view>
<view class="th">会员姓名</view>
<view class="th">核销明细</view>
</view>
<view class="tableTh" wx:for="{{list}}" wx:key="index">
<view class="tr">{{item.riqi}}</view>
<view class="tr">{{item.num}}</view>
<view class="tr">{{item.baName}}</view>
<view class="tr">{{item.phone}}</view>
<view class="tr">{{item.name}}</view>
<view class="tr">{{item.price}}</view>
</view>
</view>
</view>
</view>
</scroll-view>
// js部分 在上面data中先声明变量toView:'default'
changeSilder(e){
// console.log(e.currentTarget.dataset);
if(e.currentTarget.dataset.current == '01'){
this.setData({
toView: "xsjl"
})
}else if(e.currentTarget.dataset.current == '02'){
this.setData({
toView: "hejl"
})
}