 
  
   English 
 将页面滚动到目标位置
可以滚动到指定的scrollTop值处,也可以滚动到指定的目标元素处(通过css选择器selector), 仅支持一级 class
app-uvue下,只有页面的根元素为scroll-view时,本API才生效。详见
| 名称 | 类型 | 必填 | 默认值 | 描述 | 
|---|---|---|---|---|
| options | PageScrollToOptions | 是 | - | - | 
| 名称 | 类型 | 必备 | 默认值 | 描述 | 
|---|---|---|---|---|
| scrollTop | number | 否 | - | 滚动到页面的目标位置 | 
| selector | string | 否 | - | 选择器 | 
| offsetTop | number | 否 | - | 偏移距离,可以滚动到 selector 加偏移距离的位置 | 
| duration | number | 否 | - | 滚动动画的时长 | 
| success | (result: AsyncApiSuccessResult) => void | 否 | - | 接口调用成功的回调函数 | 
| fail | (result: UniError) => void | 否 | - | 接口调用失败的回调函数 | 
| complete | (result: AsyncApiResult) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) | 
| 名称 | 类型 | 必备 | 默认值 | 描述 | 
|---|---|---|---|---|
| errMsg | string | 是 | - | - | 
| 名称 | 类型 | 必备 | 默认值 | 描述 | 
|---|---|---|---|---|
| errMsg | string | 是 | - | - | 
| 安卓系统版本 | 安卓 uni-app | 安卓 uni-app-x | iOS 系统版本 | iOS uni-app | iOS uni-app-x | |
|---|---|---|---|---|---|---|
| offsetTop | 5.0 | x | 3.91 | 10.0 | x | x | 
scrollTop 和 selector 必须指定其中一个属性,否者触发 fail 回调
| 安卓系统版本 | 安卓 uni-app | 安卓 uni-app-x | iOS 系统版本 | iOS uni-app | iOS uni-app-x | 
|---|---|---|---|---|---|
| 5.0 | √ | 3.91 | 10.0 | √ | √ | 
selector 语法
selector类似于 CSS 的选择器,但仅支持下列语法。
.a-class.another-class.the-parent > .the-child.the-ancestor .the-descendant.the-ancestor >>> .the-descendant#a-node, .some-other-nodesscroll-with-animation="true",详见示例
uni.pageScrollTo({
	scrollTop: 0,
	duration: 300
});
| 名称 | 类型 | 必备 | 默认值 | 描述 | 
|---|---|---|---|---|
| errMsg | string | 是 | - | 错误信息 |