scroll-view 组件:可滚动视图区域。用于区域滚动。需注意在webview渲染的页面中,区域滚动的性能不及页面滚动。
官方API:uni-app官网
自动滚动到高亮序号(scroll-view的scroll-into-view+对应id值)
vue文件内容:
dom:
<scroll-view scroll-y :scroll-into-view="seqToView">
<view class="pop-scroll">
<view
v-for="(item,index) in seqList"
:id="'seq-' + item"
:key="index"
class="pop-seq"
:class="seqIndex === index ? 'active' : ''"
@click="selSeq(item,index)"
>
<text>{{ item }}</text>
</view>
</view>
</scroll-view>
滚动若太生硬,可加滚动过度效果属性 scroll-with-animation="true"
data:
seqToView: '' // 滚动至序号
js:
this.seqToView = 'seq-' + this.queNum // 滚动至选中序号位置