微信小程序API 滚动


本文整理自网络,侵删。

wx.pageScrollTo(Object object)

基础库 1.4.0 开始支持,低版本需做兼容处理。

将页面滚动到目标位置,支持选择器和滚动距离两种方式定位

参数

Object object

属性类型默认值必填说明最低版本
scrollTopnumber滚动到页面的目标位置,单位 px
durationnumber300滚动动画的时长,单位 ms
selectorstring选择器2.7.3
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)

selector 语法

selector类似于 CSS 的选择器,但仅支持下列语法。

  • ID选择器:#the-id
  • class选择器(可以连续指定多个):.a-class.another-class
  • 子元素选择器:.the-parent > .the-child
  • 后代选择器:.the-ancestor .the-descendant
  • 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
  • 多选择器的并集:#a-node, .some-other-nodes

示例代码

wx.pageScrollTo({
  scrollTop: 0,
  duration: 300
})



标签:微信小程序

相关阅读 >>

微信小程序 框架(mina)

微信小程序api nfc-监听接受消息事件

微信小程序云开发服务端api 工具类

微信小程序 api

微信小程序 运力方使用onorderreadd

微信小程序云开发 发票管理

sdk数据库 aggregate随机选定记录

微信小程序api 数据缓存

sdk数据库 command聚合操作符日期操作符

微信小程序api 绘图setshadow(设置阴影样式)

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...