当前位置:网站首页>小程序:滚动到页面顶部或者某个元素位置
小程序:滚动到页面顶部或者某个元素位置
2022-06-10 06:47:00 【Lvan的前端生活】
背景
我们一般会有滚动到页面顶部、底部,或者滚动到某个元素的位置这种需求,在web中我们一般用 scroll 相关方法,具体可以看 js:可能是最全的scroll相关的方法,那么在小程序中,我们一般使用 wx.pageScrollTo
API

实践
滚动到顶部
wx.pageScrollTo({
scrollTop: 0
})
滚动到元素位置
wx.pageScrollTo({
selector: '#my-dom'
})
滚动到底部
wx.pageScrollTo({
// 可以填一个比较大的数值,也可以用元素选择器来做
scrollTop: 10000
})
边栏推荐
- Ytu - C language exercises half search
- Longest common subsequence
- loj10131. 「一本通 4.4 例 2」暗的连锁 题解 树上差分(边差分)
- Long press the page at the mobile terminal, do not copy text and single picture
- Fastjson利用笔记
- A brief introduction to the difference between static web pages and dynamic web pages webl Differences between 0 and Web2.0 brief introduction to the differences between get and post methods
- Business topic: user growth analysis
- 618 大促来袭,浅谈如何做好大促备战
- Qt--- create dialog 2: quick dialog design
- Baidu cloud address identification
猜你喜欢

How to solve mysql1045 and find the prompt is not an internal command

ROS2+Gazebo11+Car+OpenCV巡线识别和速度转向控制学习

Matlab: 多项式表示及其基本运算

Multiple solutions to one problem × 5 (array + circular linked list)

Business topic: user usage path analysis

TeleyeControlor V8.16发布 完成注册表功能

Getting started with pytorch: training a deep neural network (DNN)

3DMAX modeling scenario

Teleyecontroller v8.47 release changes socket framework

Instagram CEO: "Apple iPad is not very popular, and it is not worth developing an exclusive version of the app"
随机推荐
SQL practice: SQL foundation and execution sequence
Fix a button in the lower right corner
Yosezang original signature locator signaturetest v6.36 RLS release
Daily practice: Longest symmetric string (pay attention to the last two methods)
Marketing strategy and supply forecast report of China's rice industry from 2022 to 2027 (New Edition)
TeleyeControlor V8.47版本发布 更改Socket框架
Jumping game II
Spark avoids repeatedly parsing JSON for a column
The game crashed after the computer added a new memory module, and the browser blocked the blue screen of the computer
How to solve mysql1045 and find the prompt is not an internal command
微信团队分享:微信后台在海量并发请求下是如何做到不崩溃的
简述静态网页和动态网页的区别 Webl.0 和 Web2.0 的区别 简述 GET 和 POST 方法的区别
Qt--- create dialog 2: quick dialog design
Ytu - C language exercises half search
原博客的地址
Nignx configuring websocket
最长公共子序列
TeleyeControlor V8.69 重构键盘记录功能发布 By:Yose
3DMAX Dragon
ShardingSphere实践(6)——弹性伸缩