Skip to content

mpx.pageScrollTo(Object object)

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

支持情况: 微信、支付宝、web

参考文档

参数

Object object

属性类型默认值必填说明最低版本支付宝web
scrollTopnumber滚动到页面的目标位置,单位 px
durationnumber300滚动动画的时长,单位 ms
selectorstring选择器2.7.3
offsetTopnumber偏移距离,需要和 selector 参数搭配使用,可以滚动到 selector 加偏移距离的位置,单位 px2.23.1
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

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