微信小程序锚点跳转

 <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

posted @ 2021-11-02 14:26  到此灬一游丿  阅读(229)  评论(0编辑  收藏  举报