当前位置:网站首页>Applet: scroll to the top of the page or an element position

Applet: scroll to the top of the page or an element position

2022-06-10 06:57:00 Front end life of Lvan

background

We usually scroll to the top of the page 、 Bottom , Or the need to scroll to the location of an element , stay web We usually use scroll Related methods , For details, see js: Probably the most complete scroll Related methods , So in the applet , We usually use wx.pageScrollTo

API

 Insert picture description here

practice

Scroll to top

wx.pageScrollTo({
    
  scrollTop: 0
})

Scroll to element position

wx.pageScrollTo({
    
  selector: '#my-dom'
})

Scroll to the bottom

wx.pageScrollTo({
    
  //  You can fill in a large number , You can also use element selectors to do 
  scrollTop: 10000
})
原网站

版权声明
本文为[Front end life of Lvan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100646503317.html