微信小程序锚点跳转
<scroll-view class="nav-right" scroll-into-view="{{toView}}" scroll-y="true" scroll-with-animation="true"> 这个是可以滚动的容器 <view id="goid">要跳转的子元素</view> </scroll-view>
scroll-into-view :绑定要跳转的子元素id scroll-y:表示Y轴滚动 scroll-with-animation :滚动动画
只需要点击按钮把 toView 变成需要跳转元素的id即可
data:{ toView:"" } onclick(){ this.setData({ toView:"goid" }) }
详细内容:https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html