1.主要使用uniapp scroll-view 组件的scroll-into-view属性实现功能
2.代码如下
<scroll-view
:scroll-into-view="intoView"
>
<u-tabs
class="tabs-list"
@change="tabChange"
:list="tabList"
>
</u-tabs>
<view id="1"></view>
<view id="2"></view>
<view id="3"></view>
<view id="4"></view>
</scroll-view>
tabList: [
{
name: "1",
id: "1",
},
{
name: "2",
id: "2",
},
{
name: "3",
id: "3",
},
{
name: "4",
id: "5",
},
],
intoView: "",
tabChange(e) {
this.intoView = e.id;
},