做网站需要做哪些东西,体彩网站建设,网站优化首页付款,电商商城网站开发需求#xff1a;在页面中#xff0c;不管位于何处#xff0c;点击按钮页面滚动到对应的标题位置。
最简单有效的方式#xff08;直接复制改数据就行#xff09;
使用 scroll-view 标签的属性#xff1a;scroll-top(距离值 num) 或 scroll-into-view(子元素的id,不能以…需求在页面中不管位于何处点击按钮页面滚动到对应的标题位置。
最简单有效的方式直接复制改数据就行
使用 scroll-view 标签的属性scroll-top(距离值 num) 或 scroll-into-view(子元素的id,不能以数字开头 string);
scroll-view classscroller :scroll-into-viewtoView scroll-ytrue scroll-with-animationtrue你渲染的内容
/scroll-view
点击事件(位置随便写根据页面需求)
p v-for(item,index) in gameList[current-1].list :keyindex tapfilterList(item.name){{item.name}}
/p
需要滚动到的地方使用动态id
p :iditem.name{{item.name}}/p
事件
filterList(id) {uni.createSelectorQuery().select(# id).boundingClientRect(function(rect){// 使用scrollIntoView方法滚动到目标元素uni.pageScrollTo({scrollTop: rect.top - 70,duration: 300})}).exec();}, 总体思路
1.使用scroll-view 标签并配置
2.点击事件获取想要的id
3.设置滚动距离时长